本文整理汇总了C++中IDispatchPtr::GetIDsOfNames方法的典型用法代码示例。如果您正苦于以下问题:C++ IDispatchPtr::GetIDsOfNames方法的具体用法?C++ IDispatchPtr::GetIDsOfNames怎么用?C++ IDispatchPtr::GetIDsOfNames使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类IDispatchPtr
的用法示例。
在下文中一共展示了IDispatchPtr::GetIDsOfNames方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1:
bool CExcelDOMStripperStrategy::Excel2007MarkedAsFinal(IDispatchPtr spDispWorkbook)
{
if (Excel2007(spDispWorkbook))
{
DISPID dispid = 0;
LPOLESTR propertyName = L"Final";
HRESULT hr = spDispWorkbook->GetIDsOfNames(IID_NULL, &propertyName, 1, LOCALE_SYSTEM_DEFAULT, &dispid);
if(FAILED(hr))
{
std::tostringstream msg;
msg << _T("Failed to obtain the dispid of the [Final] property on the Workbook.") << std::ends;
throw Workshare::Com::ComException(msg.str().c_str(), hr, spDispWorkbook);
}
short value = 0;
hr = _com_dispatch_propget(spDispWorkbook, dispid, VT_BOOL, (void*)&value);
if(FAILED(hr))
{
std::tostringstream msg;
msg << _T("Failed to obtain the [Final] property on the Workbook.") << std::ends;
throw Workshare::Com::ComException(msg.str().c_str(), hr, spDispWorkbook);
}
if (value == -1)
return true;
}
return false;
}
示例2: GetObjectType
SolidEdgeConstants::ObjectType GetObjectType(IDispatchPtr pDispatch)
{
HRESULT hr = S_OK;
if (pDispatch != NULL)
{
DISPID rgDispId = 0;
OLECHAR *Names[1] = { L"Type" };
VARIANT varResult;
VariantInit(&varResult);
V_VT(&varResult) = VT_I4;
DISPPARAMS disp = { NULL, NULL, 0, 0 };
// Get the DISPID of the 'Type' property.
IfFailGo(pDispatch->GetIDsOfNames(IID_NULL, Names, 1, LOCALE_USER_DEFAULT, &rgDispId));
// Invoke the 'Type' property.
IfFailGo(pDispatch->Invoke(rgDispId, IID_NULL, LOCALE_USER_DEFAULT, DISPATCH_PROPERTYGET, &disp, &varResult, NULL, NULL));
return (SolidEdgeConstants::ObjectType)(V_I4(&varResult));
}
Error:
return (SolidEdgeConstants::ObjectType)0;
}
示例3: DoesMethodExistOnInterface
bool CCOMDispatchHelper::DoesMethodExistOnInterface(const IDispatchPtr& spDisp, LPCTSTR lszMethodName)
{
USES_CONVERSION;
DISPID rgDispId = 0;
OLECHAR FAR* szMember = T2OLE(const_cast<LPTSTR>(lszMethodName));
HRESULT hr = spDisp->GetIDsOfNames(IID_NULL, &szMember, 1, LOCALE_SYSTEM_DEFAULT, &rgDispId);
return (S_OK == hr && -1 != rgDispId);
}
示例4: IsJSFunctionKnown
bool vmsDomHelper::IsJSFunctionKnown(IHTMLDocument *pDoc, BSTR bsFuncName)
{
ATLASSERT (pDoc != NULL);
if (!pDoc)
return false;
IDispatchPtr spScript;
HRESULT hr = pDoc->get_Script (&spScript);
if (spScript == NULL)
return false;
DISPID did = NULL;
hr = spScript->GetIDsOfNames (IID_NULL, &bsFuncName, 1, LOCALE_SYSTEM_DEFAULT, &did);
return SUCCEEDED (hr);
}
示例5: TryLoadXML
void CWebWindow::TryLoadXML()
{
if(m_bQueryAttachXML&&m_AttachLoadXML.Length())
{
HRESULT hr = S_OK;
IUnknownPtr spUnk = m_browser.GetControlUnknown();
/////////
// Run Script
////////
if(spUnk)
{
CComQIPtr<IWebBrowser2, &IID_IWebBrowser2> spWB2(spUnk);
if(spWB2)
{
IDispatchPtr spDispDoc = NULL;
hr = spWB2->get_Document(&spDispDoc);
if(spDispDoc)
{
CComQIPtr<IHTMLDocument, &IID_IHTMLDocument> spDoc(spDispDoc);
if(spDoc)
{
IDispatchPtr spDispScript = NULL;
hr = spDoc->get_Script(&spDispScript);
if(spDispScript)
{
DISPID dispid = -1;
OLECHAR FAR* szMember = L"LoadXML";
hr = spDispScript->GetIDsOfNames(IID_NULL, &szMember, 1, LOCALE_SYSTEM_DEFAULT, &dispid);
if(SUCCEEDED(hr))
{
CComVariant* pvars = new CComVariant[1];
pvars[0] = CComVariant((BSTR)m_AttachLoadXML);
DISPPARAMS params = { pvars, NULL, 1, 0 };
hr = spDispScript->Invoke(dispid, IID_NULL, LOCALE_USER_DEFAULT, DISPATCH_METHOD, ¶ms, NULL, NULL, NULL);
delete []pvars;
}
}
}
}
}
}
}
}
示例6: ConvertVariants
/* void setProperty (in string propertyName, in string propertyValue); */
NS_IMETHODIMP
nsScriptablePeer::SetProperty(const char *propertyName, nsIVariant *propertyValue)
{
HRESULT hr;
DISPID dispid;
IDispatchPtr disp;
if (FAILED(GetIDispatch(&disp)))
{
return NPERR_GENERIC_ERROR;
}
USES_CONVERSION;
OLECHAR* szMember = A2OLE(propertyName);
hr = disp->GetIDsOfNames(IID_NULL, &szMember, 1, LOCALE_USER_DEFAULT, &dispid);
if (FAILED(hr))
{
return NPERR_GENERIC_ERROR;
}
_variant_t v;
ConvertVariants(propertyValue, &v);
DISPID dispIdPut = DISPID_PROPERTYPUT;
DISPPARAMS functionArgs;
_variant_t vResult;
functionArgs.rgdispidNamedArgs = &dispIdPut;
functionArgs.rgvarg = &v;
functionArgs.cArgs = 1;
functionArgs.cNamedArgs = 1;
hr = disp->Invoke(
dispid,
IID_NULL,
LOCALE_USER_DEFAULT,
DISPATCH_PROPERTYPUT,
&functionArgs, &vResult, NULL, NULL);
if (FAILED(hr))
{
return NPERR_GENERIC_ERROR;
}
return NS_OK;
}
示例7: ExecJScript
HRESULT vmsDomHelper::ExecJScript(IHTMLDocument *pDoc, BSTR bstrFuncName, const vector <CComVariant>& vArgs, CComVariant &vaResult)
{
ATLASSERT (pDoc != NULL);
if (!pDoc)
return E_INVALIDARG;
IDispatchPtr spScript;
HRESULT hr = pDoc->get_Script (&spScript);
if (spScript == NULL)
return hr;
DISPID did = NULL;
hr = spScript->GetIDsOfNames (IID_NULL, &bstrFuncName, 1, LOCALE_SYSTEM_DEFAULT, &did);
if (FAILED (hr))
return hr;
DISPPARAMS dparams;
ZeroMemory (&dparams, sizeof (dparams));
dparams.cArgs = vArgs.size ();
if (dparams.cArgs)
dparams.rgvarg = new VARIANT [dparams.cArgs];
for (int i = 0; i < vArgs.size (); i++)
{
CComVariant vaTmp; vaTmp.Copy (&vArgs [vArgs.size () - i - 1]);
VariantInit (&dparams.rgvarg [i]);
vaTmp.Detach (&dparams.rgvarg [i]);
}
EXCEPINFO ei;
ZeroMemory (&ei, sizeof (ei));
UINT nArgErr = (UINT)-1;
hr = spScript->Invoke (did, IID_NULL, 0, DISPATCH_METHOD, &dparams, &vaResult, &ei, &nArgErr);
if (dparams.rgvarg)
{
for (int i = 0; i < dparams.cArgs; i++)
VariantClear (&dparams.rgvarg [i]);
delete [] dparams.rgvarg;
}
return hr;
}
示例8: AutoWrap
HRESULT CCOMDispatchHelper::AutoWrap(int autoType, VARIANT* pvResult, const IDispatchPtr& spDisp,
LPOLESTR ptName, int cArgs...)
{
if(spDisp == 0)
return E_INVALIDARG;
va_list marker;
va_start(marker, cArgs);
DISPPARAMS dp = { NULL, NULL, 0, 0 };
DISPID dispidNamed = DISPID_PROPERTYPUT;
DISPID dispID;
HRESULT hr;
TCHAR szName[MAX_PATH];
WideCharToMultiByte(CP_ACP, 0, ptName, -1, (LPSTR)szName, 256, NULL, NULL);
hr = spDisp->GetIDsOfNames(IID_NULL, &ptName, 1, LOCALE_USER_DEFAULT, &dispID);
RETURN_FAILED(hr);
VARIANT *pArgs = new VARIANT[cArgs+1];
for(int i=0; i<cArgs; i++)
pArgs[i] = va_arg(marker, VARIANT);
dp.cArgs = cArgs;
dp.rgvarg = pArgs;
if(autoType & DISPATCH_PROPERTYPUT)
{
dp.cNamedArgs = 1;
dp.rgdispidNamedArgs = &dispidNamed;
}
hr = spDisp->Invoke(dispID, IID_NULL, LOCALE_SYSTEM_DEFAULT, autoType, &dp, pvResult, NULL, NULL);
va_end(marker);
delete [] pArgs;
return hr;
}