开发者

How to find the function name, which is going to be invoked?

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 = 0x开发者_如何学Python18?

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


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.


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));
}
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜