tags:

views:

45

answers:

2

I got:

InvokeHelper(0x18, DISPATCH_METHOD, VT_I4, (void*)&result, NULL);

How to get function name, if we have the object method or property specified by dwDispID = 0x18?

void AFX_CDECL InvokeHelper(
   DISPID dwDispID,
   WORD wFlags,
   VARTYPE vtRet,
   void* pvRet,
   const BYTE* pbParamInfo,
   ... 
);
A: 

I would try to get a ITypeInfo interface on the object (CWnd::GetControlUnknown, IUnknown::QueryInterface). Then you can use the ITypeInfo::GetNames function with your member ID (0x18) to get the name of the method.

MartinStettner
Can you give some example?
Dzen
Sorry, I have not the time right now to dig into MSDN to get the syntax right. I don't want to publish examples that do not work. Either you try to figure it out by sourself (search for the mentioned functions/interfaces in MSDN) or you'll have to wait until tomorrow :-) ...
MartinStettner
A: 

Here's a simple sample of how to fetch the name

void CTestDlg::OnTypeinfo()
{
    HRESULT hr = S_OK;

    COleDispatchDriver sc;

    sc.CreateDispatch("Omtool.ServConnect.1"); // change for your type

    CComPtr<ITypeInfo> pti;

    hr = sc.m_lpDispatch->GetTypeInfo(0, GetUserDefaultLCID(), &pti);
    ASSERT(SUCCEEDED(hr));

    CComBSTR bstrName;
    UINT nCount = 0;

    hr = pti->GetNames(0x2, &bstrName, 1, &nCount); // change 0x2 for your ID
    ASSERT(SUCCEEDED(hr));
}
Ruddy