本文整理汇总了C++中CComSafeArray::GetLowerBound方法的典型用法代码示例。如果您正苦于以下问题:C++ CComSafeArray::GetLowerBound方法的具体用法?C++ CComSafeArray::GetLowerBound怎么用?C++ CComSafeArray::GetLowerBound使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CComSafeArray
的用法示例。
在下文中一共展示了CComSafeArray::GetLowerBound方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: BstrPrintf
STDMETHODIMP CConsoleObject::BstrPrintf(BSTR* ret, const SAFEARRAY& varg) const
{
//DUMP_VARIANTSAFEARRAY(&varg);
if (ret == NULL)
return E_POINTER;
CComSafeArray<VARIANT> safearray;
HRESULT hr = safearray.Attach(&varg);
if (FAILED(hr)) return hr;
if (safearray.GetDimensions() != 1)
return E_INVALIDARG;
CAtlString result(_T(""));
_variant_t current;
int upper = safearray.GetUpperBound() + 1;
for (int i = safearray.GetLowerBound(); i < upper; i++) {
current.Attach(safearray[i]);
if (current.vt == VT_I4) {
result.AppendFormat(_T("%ld"), current.lVal);
} else if (current.vt == VT_BSTR) {
_bstr_t str(current.bstrVal);
int specCount = 0;
TCHAR* lastFound = str;
TCHAR* found;
TCHAR next;
int specLength = 0;
found = _tcschr(str, _T('%'));
if (found == NULL) {
result += static_cast<TCHAR*>(str);
} else {
while (found) {
next = *(found + 1);
switch (next) {
case _T('%') : {
specLength = 2;
result.CopyChars(result.GetBuffer(), lastFound,
static_cast<int>(found + 1 - lastFound));
}
case _T('s') : {
specLength = 2;
_variant_t varstr;
GET_NEXT_VARIANT(varstr, VT_BSTR);
result.Append(lastFound, static_cast<int>(found - lastFound));
result += varstr.bstrVal;
break;
}
case _T('d') : {
specLength = 2;
_variant_t varint;
GET_NEXT_VARIANT(varint, VT_I4);
result.Append(lastFound, static_cast<int>(found - lastFound));
result.AppendFormat(_T("%ld"), varint.lVal);
break;
}
case _T('f') : {
specLength = 2;
//GET_NEXT_VARIANT(VT_R8);
break;
}
case _T('x') :
break;
default:
break;
}
found += specLength;
lastFound = found;
found = _tcschr(found, _T('%'));
} // while loop
}
} else {
result += _T("[unsupported argument type]");
}
result += _T(' ');
current.Detach();
} // for loop
safearray.Detach();
result.SetAt(result.GetLength() - 1, _T('\0'));
BSTR tmp = result.AllocSysString();
if (tmp == NULL) return E_OUTOFMEMORY;
*ret = tmp;
//.........这里部分代码省略.........