本文整理汇总了C++中LPDISPATCH::Invoke方法的典型用法代码示例。如果您正苦于以下问题:C++ LPDISPATCH::Invoke方法的具体用法?C++ LPDISPATCH::Invoke怎么用?C++ LPDISPATCH::Invoke使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类LPDISPATCH
的用法示例。
在下文中一共展示了LPDISPATCH::Invoke方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: AutoDispInvoke
HRESULT WSAccessor::AutoDispInvoke(LPDISPATCH pdisp, LPOLESTR pwszname, DISPID dspid,
WORD wflags, DWORD cargs, VARIANT* rgargs, VARIANT* pvtret)
{
HRESULT hr;
DISPID dspidPut = DISPID_PROPERTYPUT;
DISPPARAMS dspparm = {NULL, NULL, 0, 0};
CHECK_NULL_RETURN(pdisp, E_POINTER);
dspparm.rgvarg = rgargs;
dspparm.cArgs = cargs;
if ((wflags & DISPATCH_PROPERTYPUT) || (wflags & DISPATCH_PROPERTYPUTREF))
{
dspparm.rgdispidNamedArgs = &dspidPut;
dspparm.cNamedArgs = 1;
}
try
{
if (pwszname)
{
hr = pdisp->GetIDsOfNames(IID_NULL, &pwszname, 1, LOCALE_USER_DEFAULT, &dspid);
//RETURN_ON_FAILURE(hr);
if( FAILED(hr))
{
*(_variant_t*)pvtret = L"方法名获取失败,可能拼写错误!";
return hr;
}
}
hr = pdisp->Invoke(dspid, IID_NULL, LOCALE_USER_DEFAULT,
(WORD)(DISPATCH_METHOD | wflags), &dspparm, pvtret, NULL, NULL);
}
catch(...)
{
hr = S_FALSE;
}
return hr;
}
示例2: GetOutlookApp
HRESULT CMyAddin::GetOutlookApp(IExchExtCallback *pmecb,
Outlook::_ApplicationPtr &rOLAppPtr)
{
AFX_MANAGE_STATE(AfxGetStaticModuleState());
try
{
IOutlookExtCallback *pOutlook = NULL;
HRESULT hRes = pmecb->QueryInterface(IID_IOutlookExtCallback,(void **) &pOutlook);
if (pOutlook)
{
IUnknown *pUnk = NULL;
pOutlook->GetObject(&pUnk);
LPDISPATCH lpMyDispatch;
if (pUnk != NULL)
{
hRes = pUnk->QueryInterface(IID_IDispatch, (void **) &lpMyDispatch);
pUnk->Release();
}
if (lpMyDispatch)
{
OLECHAR * szApplication = L"Application";
DISPPARAMS dispparamsNoArgs = {NULL, NULL, 0, 0};
DISPID dspid;
VARIANT vtResult;
lpMyDispatch->GetIDsOfNames(IID_NULL, &szApplication, 1, LOCALE_SYSTEM_DEFAULT, &dspid);
lpMyDispatch->Invoke(dspid, IID_NULL, LOCALE_SYSTEM_DEFAULT, DISPATCH_METHOD, &dispparamsNoArgs, &vtResult, NULL, NULL);
lpMyDispatch->Release();
rOLAppPtr= vtResult.pdispVal;
return S_OK;
}
}
}
catch(...)
{
}
return S_FALSE;
}