本文整理汇总了C++中CComSafeArray::GetAt方法的典型用法代码示例。如果您正苦于以下问题:C++ CComSafeArray::GetAt方法的具体用法?C++ CComSafeArray::GetAt怎么用?C++ CComSafeArray::GetAt使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CComSafeArray
的用法示例。
在下文中一共展示了CComSafeArray::GetAt方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: getLabviewValue
void lvDCOMInterface::getLabviewValue(const char* param, T* value, size_t nElements, size_t& nIn)
{
if (value == NULL)
{
throw std::runtime_error("getLabviewValue failed (NULL)");
}
if (param == NULL || *param == '\0')
{
throw std::runtime_error("getLabviewValue: param is NULL");
}
CComVariant v;
char vi_name_xpath[MAX_PATH_LEN], control_name_xpath[MAX_PATH_LEN];
_snprintf(vi_name_xpath, sizeof(vi_name_xpath), "/lvinput/section[@name='%s']/vi/@path", m_configSection.c_str());
_snprintf(control_name_xpath, sizeof(control_name_xpath), "/lvinput/section[@name='%s']/vi/param[@name='%s']/read/@target", m_configSection.c_str(), param);
CComBSTR vi_name(doPath(vi_name_xpath).c_str());
CComBSTR control_name(doXPATH(control_name_xpath).c_str());
if (vi_name.Length() == 0 || control_name.Length() == 0)
{
throw std::runtime_error("getLabviewValue: vi or control is NULL");
}
getLabviewValue(vi_name, control_name, &v);
if ( v.vt != (VT_ARRAY | CVarTypeInfo<T>::VT) )
{
throw std::runtime_error("getLabviewValue failed (type mismatch)");
}
CComSafeArray<T> sa;
sa.Attach(v.parray);
nIn = ( sa.GetCount() > nElements ? nElements : sa.GetCount() );
for(LONG i=0; i<nIn; ++i)
{
value[i] = sa.GetAt(i);
}
sa.Detach();
}
示例2: displayCCOMBSTRFiles
void displayCCOMBSTRFiles(CComSafeArray<BSTR> fileSet)
{
std::wcout << "Displaying Files Generated from the C++ Interface from COM OBJECT" << std::endl;
for (ULONG i = 0; i < fileSet.GetCount(); i++)
{
std::cout << "Qualified File # " <<i<<" : "<< convertBSTR2stdSTR(fileSet.GetAt(i)) << "\n";
}
}
示例3: fireOnBeforeRequest
//----------------------------------------------------------------------------
//
HRESULT CAnchoRuntime::fireOnBeforeRequest(const std::wstring &aUrl, const std::wstring &aMethod, const CAnchoRuntime::FrameRecord *aFrameRecord, /*out*/ BeforeRequestInfo &aOutInfo)
{
CComPtr<ComSimpleJSObject> info;
IF_FAILED_RET(SimpleJSObject::createInstance(info));
fillRequestInfo(*info, aUrl, aMethod, aFrameRecord);
CComPtr<ComSimpleJSArray> argArray;
IF_FAILED_RET(SimpleJSArray::createInstance(argArray));
argArray->push_back(CComVariant(info.p));
CComVariant result;
m_pAnchoService->invokeEventObjectInAllExtensions(CComBSTR(L"webRequest.onBeforeRequest"), argArray.p, &result);
if (result.vt & VT_ARRAY) {
CComSafeArray<VARIANT> arr;
arr.Attach(result.parray);
//contained data already managed by CComSafeArray
VARIANT tmp = {0}; HRESULT hr = result.Detach(&tmp);
BEGIN_TRY_BLOCK
aOutInfo.cancel = false;
for (ULONG i = 0; i < arr.GetCount(); ++i) {
Ancho::Utils::JSObjectWrapperConst item = Ancho::Utils::JSValueWrapperConst(arr.GetAt(i)).toObject();
Ancho::Utils::JSValueWrapperConst cancel = item[L"cancel"];
if (!cancel.isNull()) {
aOutInfo.cancel = aOutInfo.cancel || cancel.toBool();
}
Ancho::Utils::JSValueWrapperConst redirectUrl = item[L"redirectUrl"];
if (!redirectUrl.isNull()) {
aOutInfo.redirect = true;
aOutInfo.newUrl = redirectUrl.toString();
}
}
END_TRY_BLOCK_CATCH_TO_HRESULT
}