Exemplo n.º 1
0
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;
}
Exemplo n.º 2
0
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;
}
Exemplo n.º 3
0
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");
	}
}