本文整理汇总了C++中IDispatch::Invoke方法的典型用法代码示例。如果您正苦于以下问题:C++ IDispatch::Invoke方法的具体用法?C++ IDispatch::Invoke怎么用?C++ IDispatch::Invoke使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类IDispatch
的用法示例。
在下文中一共展示了IDispatch::Invoke方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1:
HRESULT CISEMMManager::OnEvent(const EventNumberEnum EventNumber, _bstr_t Description)
{
CComVariant varResult;
int nConnectionIndex;
CComVariant* pvars = new CComVariant[2];
int nConnections = m_vec.GetSize();
HRESULT hr = S_OK;
for (nConnectionIndex = 0; nConnectionIndex < nConnections; nConnectionIndex++)
{
Lock();
CComPtr<IUnknown> sp = m_vec.GetAt(nConnectionIndex);
Unlock();
IDispatch* pDispatch = reinterpret_cast<IDispatch*>(sp.p);
if (pDispatch != NULL)
{
VariantClear(&varResult);
pvars[1] = EventNumber;
pvars[0] = (BSTR)Description;
DISPPARAMS disp = { pvars, NULL, 2, 0 };
hr = pDispatch->Invoke(0x9, IID_NULL, LOCALE_USER_DEFAULT, DISPATCH_METHOD, &disp, &varResult, NULL, NULL);
}
}
delete[] pvars;
if(FAILED(hr)) return hr;
return varResult.scode;
}
示例2: OnQuoteTickWorse
HRESULT CISEMMManager::OnQuoteTickWorse(const CComVariant& varParams,
long lTickWorseLevel, _bstr_t bsReason)
{
CComVariant varResult;
int nConnectionIndex;
CComVariant* pvars = new CComVariant[3];
int nConnections = m_vec.GetSize();
for (nConnectionIndex = 0; nConnectionIndex < nConnections; nConnectionIndex++)
{
Lock();
CComPtr<IUnknown> sp = m_vec.GetAt(nConnectionIndex);
Unlock();
IDispatch* pDispatch = reinterpret_cast<IDispatch*>(sp.p);
if (pDispatch != NULL)
{
VariantClear(&varResult);
pvars[2] = varParams;
pvars[1] = lTickWorseLevel;
pvars[0] = (BSTR)bsReason;
DISPPARAMS disp = { pvars, NULL, 3, 0 };
pDispatch->Invoke(0x3, IID_NULL, LOCALE_USER_DEFAULT, DISPATCH_METHOD, &disp, &varResult, NULL, NULL);
}
}
delete[] pvars;
return varResult.scode;
}
示例3: OnTrade
HRESULT CISEMMManager::OnTrade(const CComVariant& varParams)
{
CComVariant varResult;
int nConnectionIndex;
CComVariant* pvars = new CComVariant[1];
int nConnections = m_vec.GetSize();
HRESULT hr = S_OK;
for (nConnectionIndex = 0; nConnectionIndex < nConnections; nConnectionIndex++)
{
Lock();
CComPtr<IUnknown> sp = m_vec.GetAt(nConnectionIndex);
Unlock();
IDispatch* pDispatch = reinterpret_cast<IDispatch*>(sp.p);
if (pDispatch != NULL)
{
VariantClear(&varResult);
pvars[0] = varParams;
DISPPARAMS disp = { pvars, NULL, 1, 0 };
hr = pDispatch->Invoke(0x8, IID_NULL, LOCALE_USER_DEFAULT, DISPATCH_METHOD, &disp, &varResult, NULL, NULL);
}
}
delete[] pvars;
if(FAILED(hr)) return hr;
return varResult.scode;
}
示例4: Subscribed
void CMyTrackPriceInfoWithNotify::Subscribed(CComVariant &varParams)
{
ATLTRACE(_T("CMyTrackPriceInfoWithNotify::OnSubscribed\n"));
CComVariant varResult;
int nConnectionIndex;
CComVariant* pvars = new CComVariant[1];
int nConnections = m_vec.GetSize();
HRESULT hr = S_OK;
for (nConnectionIndex = 0; nConnectionIndex < nConnections; nConnectionIndex++)
{
Lock();
CComPtr<IUnknown> sp = m_vec.GetAt(nConnectionIndex);
Unlock();
IDispatch* pDispatch = reinterpret_cast<IDispatch*>(sp.p);
if (pDispatch != NULL)
{
VariantClear(&varResult);
pvars[0] = varParams;
DISPPARAMS disp = { pvars, NULL, 1, 0 };
hr = pDispatch->Invoke(0x4, IID_NULL, LOCALE_USER_DEFAULT, DISPATCH_METHOD, &disp, &varResult, NULL, NULL);
}
}
delete[] pvars;
}
示例5: OnError
//-----------------------------------------------------------------------------------------------//
HRESULT CTrackDataStructureProvider::OnError(ErrorNumberEnum enumError, _bstr_t bstrDescription,
RequestsTypeEnum enumRequest, CComVariant &varRequest)
{
ATLTRACE(_T("CMyTrackStructureProvider::OnError\n"));
CComVariant varResult;
int nConnectionIndex;
CComVariant* pvars = new CComVariant[4];
int nConnections = m_vec.GetSize();
HRESULT hr = S_OK;
for (nConnectionIndex = 0; nConnectionIndex < nConnections; nConnectionIndex++)
{
Lock();
CComPtr<IUnknown> sp = m_vec.GetAt(nConnectionIndex);
Unlock();
IDispatch* pDispatch = reinterpret_cast<IDispatch*>(sp.p);
if (pDispatch != NULL)
{
VariantClear(&varResult);
pvars[3] = enumError;
pvars[2] = (BSTR)bstrDescription;
pvars[1] = enumRequest;
pvars[0] = varRequest;
DISPPARAMS disp = { pvars, NULL, 4, 0 };
hr = pDispatch->Invoke(0x3, IID_NULL, LOCALE_USER_DEFAULT, DISPATCH_METHOD, &disp, &varResult, NULL, NULL);
}
}
delete[] pvars;
if(FAILED(hr)) return hr;
return varResult.scode;
}
示例6: OnOption
//-----------------------------------------------------------------------------------------------//
HRESULT CTrackDataStructureProvider::OnOption(CComVariant &varParams, CComVariant &varResults, CComVariant &varIsLastOption)
{
ATLTRACE(_T("CMyTrackStructureProvider::OnOption\n"));
HRESULT hr = S_OK ;
CComVariant varResult;
int nConnectionIndex;
CComVariant* pvars = new CComVariant[3];
int nConnections = m_vec.GetSize();
for (nConnectionIndex = 0; nConnectionIndex < nConnections; nConnectionIndex++)
{
Lock();
CComPtr<IUnknown> sp = m_vec.GetAt(nConnectionIndex);
Unlock();
IDispatch* pDispatch = reinterpret_cast<IDispatch*>(sp.p);
if (pDispatch != NULL)
{
VariantClear(&varResult);
pvars[2] = varParams;
pvars[1] = varResults;
pvars[0] = varIsLastOption;
DISPPARAMS disp = { pvars, NULL, 3, 0 };
hr = pDispatch->Invoke(0x2, IID_NULL, LOCALE_USER_DEFAULT, DISPATCH_METHOD, &disp, &varResult, NULL, NULL);
}
}
delete[] pvars;
if(FAILED(hr)) return hr;
return varResult.scode;
}
示例7: getAtomProperty
Atom MSIDispatchConsumer::getAtomProperty(Atom name) const {
AXTam *axcore = (AXTam *)core();
IDispatch *disp = (IDispatch *)getDispatch();
if (!axcore->isString(name))
axcore->toplevel->throwTypeError(kCheckTypeFailedError);
DISPID id;
OLECHAR *olename = (OLECHAR *)axcore->atomToString(name)->c_str();
HRESULT hr = disp->GetIDsOfNames(IID_NULL, &olename, 1, 0, &id);
if (hr == DISP_E_UNKNOWNNAME) {
// not a name this object has - do we need to see if its builtin?
// If we call ScriptObject::getAtomProperty() with an unknown name,
// it throws an exception, where we just want undefinedAtom.
// XXX - but we must call the base for now to resolve 'Object' etc
//return ScriptObject::getAtomProperty(name);
return undefinedAtom;
}
if (FAILED(hr))
axcore->throwCOMConsumerError(hr);
EXCEPINFO ei;
DISPPARAMS params = {NULL, NULL, 0, 0};
CComVariant ret;
hr = disp->Invoke(id, IID_NULL, 0, DISPATCH_PROPERTYGET, ¶ms, &ret, &ei, NULL);
if (FAILED(hr))
axcore->throwCOMConsumerError(hr, &ei);
return axcore->toAtom(ret);
}
示例8: OnQuotesSent
HRESULT CISEMMManager::OnQuotesSent(const CComVariant& varParams, ErrorNumberEnum Error, bstr_t bsOrderID)
{
CComVariant varResult;
int nConnectionIndex;
CComVariant* pvars = new CComVariant[3];
int nConnections = m_vec.GetSize();
for (nConnectionIndex = 0; nConnectionIndex < nConnections; nConnectionIndex++)
{
Lock();
CComPtr<IUnknown> sp = m_vec.GetAt(nConnectionIndex);
Unlock();
IDispatch* pDispatch = reinterpret_cast<IDispatch*>(sp.p);
if (pDispatch != NULL)
{
VariantClear(&varResult);
pvars[2] = varParams;
pvars[1] = Error;
pvars[0] = (BSTR)bsOrderID;
DISPPARAMS disp = { pvars, NULL, 3, 0 };
HRESULT hr = pDispatch->Invoke(0x4, IID_NULL, LOCALE_USER_DEFAULT, DISPATCH_METHOD, &disp, &varResult, NULL, NULL);
}
}
delete[] pvars;
return varResult.scode;
}
示例9: getFighterLocation
/*
* Get the location of a fighter.
*/
bool CComPlugin::getFighterLocation(const int party, const int idx, int &x, int &y)
{
if (!m_plugin) return false;
const MEMBERID member = m_members[MEMBER_GETFIGHTERLOCATION];
if (member == DISPID_UNKNOWN) return false;
// Arguments in *reverse* order.
CComVariant vars[4], ret;
vars[3] = party;
vars[2] = idx;
vars[1].vt = VT_I4 | VT_BYREF;
vars[1].plVal = (long *)&x;
vars[0].vt = VT_I4 | VT_BYREF;
vars[0].plVal = (long *)&y;
DISPPARAMS params = {vars, NULL, 4, 0};
HRESULT hr = m_plugin->Invoke(
member,
IID_NULL,
LOCALE_USER_DEFAULT,
DISPATCH_METHOD,
¶ms,
&ret,
NULL,
NULL
);
return (ret.boolVal == VARIANT_TRUE);
}
示例10: OnLastQuote
HRESULT CHyperFeedPriceProvider::OnLastQuote(const CComVariant &varParams,const CComVariant &varResults)
{
ATLTRACE(_T("CHyperFeedPriceProvider::OnLastQuote\n"));
CComVariant varResult;
int nConnectionIndex;
CComVariant* pvars = new CComVariant[2];
int nConnections = m_vec.GetSize();
HRESULT hr = S_OK;
for (nConnectionIndex = 0; nConnectionIndex < nConnections; nConnectionIndex++)
{
Lock();
CComPtr<IUnknown> sp = m_vec.GetAt(nConnectionIndex);
Unlock();
IDispatch* pDispatch = reinterpret_cast<IDispatch*>(sp.p);
if (pDispatch != NULL)
{
VariantClear(&varResult);
pvars[1] = varParams;
pvars[0] = varResults;
DISPPARAMS disp = { pvars, NULL, 2, 0 };
hr = pDispatch->Invoke(0x1, IID_NULL, LOCALE_USER_DEFAULT, DISPATCH_METHOD, &disp, &varResult, NULL, NULL);
}
}
delete[] pvars;
if(FAILED(hr)) return hr;
return varResult.scode;
}
示例11: Execute
VARIANT ObjectInstance::Execute(const wstring methodName, DISPPARAMS inputParameters)
{
if (this->objectHandle == NULL)
{
throw new RuntimeHostException("ObjectHandle is no longer valid");
}
VARIANT v;
DISPID dispid;
LPOLESTR szMethodName = _bstr_t(methodName.data());
VARIANT result;
EXCEPINFO pExcepInfo;
unsigned int puArgErr = 0;
// Initialze the variants
VariantInit(&v);
VariantInit(&result);
HRESULT hr = this->objectHandle->Unwrap(&v);
if (!SUCCEEDED(hr))
{
throw new RuntimeHostException("Unable to retrieve method information");
}
// The .NET Component should expose IDispatch
IDispatch* pdispatch = v.pdispVal;
// Retrieve the DISPID
hr = pdispatch->GetIDsOfNames(
IID_NULL,
&szMethodName,
1,
LOCALE_SYSTEM_DEFAULT,
&dispid);
if (!SUCCEEDED(hr))
{
throw new RuntimeHostException("Unable to retrieve method information");
}
// Invoke the method on the IDispatch Interface
hr = pdispatch->Invoke(
dispid,
IID_NULL,
LOCALE_SYSTEM_DEFAULT,
DISPATCH_METHOD,
&inputParameters,
&result,
&pExcepInfo,
&puArgErr);
if (!SUCCEEDED(hr))
{
throw new RuntimeHostException("Error on method execution");
}
return result;
}
示例12: PrintDocument
// Prints the WORD document if everything goes fine
// otherwise error is returned
int CAutoWord::PrintDocument(char *strFilePath)
{
// Open the document
VARIANT varRetVal;
EXCEPINFO excepInfo; // this variable contains exception info if any Invoke call fails
VARIANTARG varg;
varg.vt = VT_BSTR;
varg.bstrVal = _bstr_t(strFilePath); // this is the MS-word document filename, must be changed to a valid filename that exists on disk
DISPPARAMS dpOpen = { &varg, NULL, 1, 0 };
DISPID dispOpenID;
LPOLESTR szOpenDoc = L"Open";
HRESULT hr = m_pDocuments->GetIDsOfNames(IID_NULL, &szOpenDoc, 1, LOCALE_SYSTEM_DEFAULT, &dispOpenID);
hr = m_pDocuments->Invoke(dispOpenID, IID_NULL, LOCALE_SYSTEM_DEFAULT, DISPATCH_METHOD, &dpOpen, &varRetVal, &excepInfo, NULL);
if (FAILED(hr))
{
OutputDebugString("Error opening the document\n");
Destroy();
return -1;
}
IDispatch* pDocument = varRetVal.pdispVal;
// Call PrintOut method of the opened Document
DISPPARAMS dpPrint = { NULL, NULL, 0, 0 };
DISPID dispPrintID;
LPOLESTR szPrintDoc = L"PrintOut";
hr = pDocument->GetIDsOfNames(IID_NULL, &szPrintDoc, 1, LOCALE_SYSTEM_DEFAULT, &dispPrintID);
hr = pDocument->Invoke(dispPrintID, IID_NULL, LOCALE_SYSTEM_DEFAULT, DISPATCH_METHOD, &dpPrint, &varRetVal, NULL, NULL);
if (FAILED(hr))
{
OutputDebugString("The document could not be printed\n");
Destroy();
return -1;
}
// Close the document now.
DISPPARAMS dpClose = { NULL, NULL, 0, 0 };
DISPID dispCloseID;
LPOLESTR szCloseDoc = L"Close";
hr = pDocument->GetIDsOfNames(IID_NULL, &szCloseDoc, 1, LOCALE_SYSTEM_DEFAULT, &dispCloseID);
hr = pDocument->Invoke(dispCloseID, IID_NULL, LOCALE_SYSTEM_DEFAULT, DISPATCH_METHOD, &dpClose, &varRetVal, &excepInfo, NULL);
return 0;
}
示例13: invoke
void HostTimerDispatcher::invoke(UINT timerId)
{
IDispatch* pDisp = NULL;
if (!m_timerDispatchMap.query(timerId, pDisp) || !pDisp)
return;
VARIANTARG args[1];
args[0].vt = VT_I4;
args[0].lVal = timerId;
DISPPARAMS dispParams = {args, NULL, _countof(args), 0};
pDisp->Invoke(DISPID_VALUE, IID_NULL, LOCALE_USER_DEFAULT, DISPATCH_METHOD, &dispParams, NULL, NULL, NULL);
}
示例14: OnQuoteUpdate
HRESULT CISEStdPriceProvider::OnQuoteUpdate(const CComVariant &varParams,const CComVariant &varResults)
{
CComVariant varResult;
int nConnectionIndex;
CComVariant* pvars = new CComVariant[2];
int nConnections = m_vec.GetSize();
HRESULT hr = S_OK;
CComVariant _varResults;
_ISEQuoteUpdateResult ResultSrc(varResults);
_QuoteUpdateResult ResultDest;
ResultDest.Init();
ResultDest->UpdateDateTime = 0;
ResultDest->SeqNum = 0;
ResultDest->BidPrice = ResultSrc->BidPrice;
ResultDest->AskPrice = ResultSrc->AskPrice;
ResultDest->BidSize = ResultSrc->BidSize;
ResultDest->AskSize = ResultSrc->AskSize;
ResultDest->Currency = SysAllocString(ResultSrc->Currency);
ResultDest->LotSize = 0;
ResultDest->LastPrice = ResultSrc->LastPrice;
ResultDest->OpenInterest = 0;
ResultDest->Volume = 0;
ResultDest->Exchange = 0;
ResultDest.CopyTo(_varResults);
for (nConnectionIndex = 0; nConnectionIndex < nConnections; nConnectionIndex++)
{
Lock();
CComPtr<IUnknown> sp = m_vec.GetAt(nConnectionIndex);
Unlock();
IDispatch* pDispatch = reinterpret_cast<IDispatch*>(sp.p);
if (pDispatch != NULL)
{
VariantClear(&varResult);
pvars[1] = varParams;
pvars[0] = _varResults;
DISPPARAMS disp = { pvars, NULL, 2, 0 };
hr = pDispatch->Invoke(0x2, IID_NULL, LOCALE_USER_DEFAULT, DISPATCH_METHOD, &disp, &varResult, NULL, NULL);
}
}
delete[] pvars;
if(FAILED(hr)) return hr;
return varResult.scode;
}
示例15: Run
HRESULT __stdcall ScriptHost::Run(WCHAR *procname, DISPPARAMS *args, VARIANT *results)
{
assert(procname != nullptr);
if (procname == nullptr)
return E_POINTER;
IDispatch *disp = nullptr;
_activeScript->GetScriptDispatch(nullptr, &disp);
DISPID dispid = 0;
disp->GetIDsOfNames(IID_NULL, &procname, 1, LOCALE_SYSTEM_DEFAULT, &dispid);
EXCEPINFO info;
UINT argErr;
args->rgdispidNamedArgs = &dispid;
HRESULT hr = disp->Invoke(dispid, IID_NULL, NULL, DISPATCH_METHOD, args, results, &info, &argErr);
return hr;
}