在第三方 COM 模块中,我必须将结构传递给方法。
IDL 定义的重要部分如下所示:
interface ITheirInterface : IDispatch {
[id(0x0000012d)]
HRESULT TheirMethod([in] TheirStruct Attributes);
};
struct TheirStruct {
BSTR TheirFieldA;
BSTR TheirFieldB;
} TheirStruct;
我如何使用 ATL 从 C++ 调用该方法?
CComPtr<IDispatch> comPtr;
comPtr.CoCreateInstance(L"theirModule.TheirCoClass");
CComVariant returnValue;
CComVariant attribute= I_DO_NOT_KNOW_WHAT_TO_PLACE_HERE;
comPtr.Invoke1(T2COLE(L"TheirMethod"),&attribute,&returnValue);