In my C++ program I use a COM class which is implemented in a VB6 COM DLL. Let's call this class CETicketRA
. This class has a property AppliedPromotion
of type IPositionPromotion
. IPositionPromotion
is an interface defined by the same VB6 COM DLL. It has various properties and methods which I try to access from C++.
Given the following code:
IDispatch* pETicketRA = NULL;
DISPPARAMS dispParams = {0};
VARIANT result;
VariantInit(&result);
// Left out: some code to set pETicketRA ...
OLECHAR* strAppliedPromotion = L"AppliedPromotion";
DISPID dispIDAppliedPromotion = -1;
HRESULT hr = pETicketRA->GetIDsOfNames(IID_NULL, &strAppliedPromotion, 1, LOCALE_SYSTEM_DEFAULT, &dispIDAppliedPromotion);
hr = pETicketRA->Invoke(dispIDAppliedPromotion, IID_NULL, LOCALE_SYSTEM_DEFAULT, DISPATCH_PROPERTYGET, &dispParams, &result, NULL, NULL);
IDispatch* pPromo = NULL;
hr = result.pdispVal->QueryInterface(IID_IDispatch, reinterpret_cast<LPVOID*>(&pPromo));
VariantClear(&result);
Now I try to read the property Foobar
of IPositionPromotion
:
OLECHAR* strFoobar = L"Foobar";
DISPID dispIDFoobar = -1;
hr = pPromo->GetIDsOfNames(IID_NULL, &strFoobar, 1, LOCALE_SYSTEM_DEFAULT, &dispIDFoobar);
Unfortunately the last call fails with DISP_E_UNKNOWNNAME
.
Has anyone succeeded to call VB6 interface members from C++ (or C#)?