COM:如何在Invoke方法(C ++)中传递枚举参数

时间:2018-05-24 02:32:12

标签: c++ com

我将在C ++代码中调用COM方法。 COM方法需要传入枚举参数。枚举类型也在COM库中定义。

CComDispatchDriver object;
object.CoCreateInstance(L"Server.RequestManager");

const int NUM_PARAMS = 1;
// The argument actually should be a enum type, but I don't know how to do that.
CComVariant vParams[NUM_PARAMS] = {0};  

CComVariant results;
::VariantInit(&results);
HRESULT hr = session.InvokeN(L"Method", vParams, NUM_PARAMS, &results);



// COM definition is something like this

//
// Type library items
//

enum __declspec(uuid("xxxx-xxxx-xxxx-xxxx-xxxxxxxxxx"))
DataType
{
    DataType_Insert = 0,
    DataType_Update = 1,
    DataType_Delete = 2
};


struct __declspec(uuid("xxxx-xxxx-xxxx-xxxx-xxxxxxxxxx"))
IRequestManager : IDispatch
{
    //
    // Wrapper methods for error-handling
    //

    IRequestPtr CreateMethod (enum DataType dataType );

0 个答案:

没有答案