本文整理汇总了C++中CComSafeArray::Destroy方法的典型用法代码示例。如果您正苦于以下问题:C++ CComSafeArray::Destroy方法的具体用法?C++ CComSafeArray::Destroy怎么用?C++ CComSafeArray::Destroy使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CComSafeArray
的用法示例。
在下文中一共展示了CComSafeArray::Destroy方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: GetRows
STDMETHODIMP CXRecords::GetRows(VARIANT key, VARIANT* pVal)
{
if(!m_pFields)return SetErrorInfo(s_errInit);
CComSafeArray<VARIANT> bstrArray;
VARIANT* pVar;
HRESULT hr;
int i = 0;
int pos;
int count = m_listRecords->GetCount();
pos = m_pFields->FindField(key);
if(pos < 0 || pos >= (int)m_pFields->GetCount())
return DISP_E_BADINDEX;
hr = bstrArray.Create(count);
if(FAILED(hr))return hr;
pVar = (VARIANT*)bstrArray.m_psa->pvData;
for(i = 0; i < count; i ++)
{
hr = VariantCopy(&pVar[i], (VARIANT*)&m_listRecords->GetValue(i)->m_arrayVariant[pos]);
if(FAILED(hr))
{
bstrArray.Destroy();
return hr;
}
}
pVal->vt = VT_ARRAY | VT_VARIANT;
pVal->parray = bstrArray.Detach();
return S_OK;
}
示例2: get_Keys
STDMETHODIMP CBDictionary::get_Keys(VARIANT *pKeysArray)
{
CComSafeArray<VARIANT> bstrArray;
VARIANT* pVar;
HRESULT hr;
m_cs.Enter();
hr = bstrArray.Create((ULONG)m_posArray.GetCount());
if(FAILED(hr))
{
m_cs.Leave();
return hr;
}
pVar = (VARIANT*)bstrArray.m_psa->pvData;
for(int i = 0; i < (int)m_posArray.GetCount(); i ++)
{
hr = VariantCopy(&pVar[i], (VARIANT*)&m_posArray[i]->m_key);
if(FAILED(hr))
{
m_cs.Leave();
bstrArray.Destroy();
return hr;
}
}
m_cs.Leave();
pKeysArray->vt = VT_ARRAY | VT_VARIANT;
pKeysArray->parray = bstrArray.Detach();
return S_OK;
}
示例3: printHistory
void printHistory(CComVariant history) {
if (history.vt == (VT_ARRAY | VT_I2)) {
printf("Ping code history for server: ");
CComSafeArray<SHORT> codes = history.parray;
int codeCount = codes.GetCount();
for (int i = 0; i < codeCount; i++) {
printf("%hd ", codes[i]);
}
printf("\n");
codes.Destroy();
}
else {
printf("Incorrect variant type\n");
}
}