Пример #1
0
/**
 * Test QueryGetData() enumerator for the presence of CFSTR_SHELLIDLIST
 * but the absence of CFSTR_FILEDESCRIPTOR and CFSTR_FILECONTENTS.
 *
 * Format-limited version of _testQueryFormats() in DataObjectTests.h.
 */
void _testCDataObjectQueryFormats(com_ptr<IDataObject> data_object)
{
    // Test CFSTR_SHELLIDLIST (PIDL array) format succeeds
    CFormatEtc fetcShellIdList(CFSTR_SHELLIDLIST);
    BOOST_REQUIRE_OK(data_object->QueryGetData(&fetcShellIdList));

    // Test CFSTR_FILEDESCRIPTOR (FILEGROUPDESCRIPTOR) format fails
    CFormatEtc fetcDescriptor(CFSTR_FILEDESCRIPTOR);
    BOOST_CHECK(data_object->QueryGetData(&fetcDescriptor) == S_FALSE);

    // Test CFSTR_FILECONTENTS (IStream) format fails
    CFormatEtc fetcContents(CFSTR_FILECONTENTS);
    BOOST_CHECK(data_object->QueryGetData(&fetcContents) == S_FALSE);
}
Пример #2
0
com_ptr<IDataObject> data_object_from_item_array(
    com_ptr<IShellItemArray> items, com_ptr<IBindCtx> bind_ctx)
{
    com_ptr<IDataObject> data_object;
    if (items)
    {
        items->BindToHandler(
            bind_ctx.get(), BHID_DataObject, data_object.iid(),
            reinterpret_cast<void**>(data_object.out()));
    }

    // We don't care if binding succeeded - if it did, great; we pass
    // the DataObject.  If not, the data_object pointer will be NULL
    // and we can assume that no items were selected

    return data_object;
}
Пример #3
0
	type_definitions::type_definitions(com_ptr<IMetaDataImport2> metadata)
		: _metadata { metadata }
	{
		if (!metadata.get())
		{
			throw invalid_argument { "metadata must not be a nullptr" };
		}
	}
Пример #4
0
bool CSftpDirectory::Rename(
    const cpidl_t& old_file, const wstring& new_filename,
    com_ptr<ISftpConsumer> consumer)
{
    bstr_t old_file_path =
        (m_directory / remote_itemid_view(old_file).filename()).string();
    bstr_t new_file_path = (m_directory / new_filename).string();

    return m_provider->rename(
        consumer.in(), old_file_path.in(), new_file_path.in())
        == VARIANT_TRUE;
}
Пример #5
0
void do_filecontents_test(
    const com_ptr<IDataObject>& data_object, const vector<wpath>& files,
    size_t index)
{
    FORMATETC fetc = {
        CF_FILECONTENTS, NULL, DVASPECT_CONTENT, numeric_cast<LONG>(index),
        TYMED_ISTREAM
    };
    
    StorageMedium medium;
    HRESULT hr = data_object->GetData(&fetc, medium.out());
    BOOST_REQUIRE_OK(hr);

    com_ptr<IStream> stream = medium.get().pstm;
    BOOST_REQUIRE(file_stream_equivalence(files.at(index), stream));
}
Пример #6
0
void do_filedescriptor_test(
    const com_ptr<IDataObject>& data_object, const vector<wpath>& files)
{
    FORMATETC fetc = {
        CF_FILEDESCRIPTORW, NULL, DVASPECT_CONTENT, -1, TYMED_HGLOBAL
    };
    
    StorageMedium medium;
    HRESULT hr = data_object->GetData(&fetc, medium.out());
    BOOST_REQUIRE_OK(hr);

    FileGroupDescriptor fgd(medium.get().hGlobal);
    BOOST_REQUIRE_EQUAL(fgd.size(), files.size());
    for (size_t i = 0; i < files.size(); ++i)
    {
        BOOST_REQUIRE_EQUAL(fgd[i].path(), files[i].filename());
        BOOST_REQUIRE_EQUAL(fgd[i].file_size(), file_size(files[i]));
        BOOST_REQUIRE_EQUAL(
            fgd[i].last_write_time(), from_time_t(last_write_time(files[i])));
    }
}
Пример #7
0
 com_ptr(com_ptr<S>& other) : com_ptr() {
     static_assert(!std::is_same<T, S>::value, "invalid conversion construction");
     auto const hr = other.query_interface_(&ptr_);
 }
Пример #8
0
inline void
setObjectName(com_ptr<T> &pObject, const char *szName)
{
    pObject->SetPrivateData(WKPDID_D3DDebugObjectName, (UINT)strlen(szName), szName);
}
Пример #9
0
{
    // IPersist is easy to (badly) implement
    class error_object : public simple_object<IPersist>
    {
    public:
        virtual HRESULT STDMETHODCALLTYPE GetClassID(CLSID* /*class_id_out*/)
        {
            try
            {
                throw com_error("Test error message", E_NOTIMPL);
            }
            COMET_CATCH_CLASS_INTERFACE_BOUNDARY("GetClassID", "error_object")
        }
    };

    com_ptr<IPersist> broken_object = new error_object();

    CLSID clsid = CLSID();
    HRESULT hr = broken_object->GetClassID(&clsid);

    BOOST_REQUIRE_EQUAL(hr, E_NOTIMPL);

    com_error error = com_error_from_interface(broken_object, hr);
    BOOST_CHECK_EQUAL(error.s_str(), "Test error message");
    BOOST_CHECK_EQUAL(error.source().s_str(), "error_object.GetClassID");
}


// Test that error info is correct even when the exception occurs inside a
// call to a contained object and that call does not have its error info
// specifically caught and rethrow.
Пример #10
0
		void dds_reader::read(com_ptr<ID3D11Texture2D> & out_buffer, com_ptr<ID3D11ShaderResourceView> & out_srv_view)
		{
			assert(DirectXTex::CreateDDSTextureFromMemory(d3d_device::instance()->raw(), texture.bytes.data(), texture.size,
				reinterpret_cast<ID3D11Resource**>(out_buffer.GetAddressOf()), out_srv_view.GetAddressOf()) == S_OK);
		}
Пример #11
0
void test(com_ptr<ITypeInfo> x, com_ptr<ITypeLib> y)
{
    y->GetTypeInfoCount();
    y->GetTypeInfoOfGuid( uuid_t::create() );
    x->GetTypeAttr();
}