Ejemplo n.º 1
0
BOOL CADORecordset::GetFieldValue(int nIndex, COleCurrency& cyValue)
{
	_variant_t vtFld;
	_variant_t vtIndex;
	
	vtIndex.vt = VT_I2;
	vtIndex.iVal = nIndex;
	
	try
	{
		vtFld = m_pRecordset->Fields->GetItem(vtIndex)->Value;
		switch(vtFld.vt) 
		{
		case VT_CY:
			cyValue = (CURRENCY)vtFld.cyVal;
			break;
		case VT_EMPTY:
		case VT_NULL:
			{
			cyValue = COleCurrency();
			cyValue.m_status = COleCurrency::null;
			}
			break;
		default:
			return FALSE;
		}
		return TRUE;
	}
	catch(_com_error &e)
	{
		dump_com_error(e);
		return FALSE;
	}
}
Ejemplo n.º 2
0
void CEx29aView::DrawDataRow(CDC* pDC, int y)
{
    int x = 0;
    CString strTime;

    COleVariant var;
    CString str;
    CEx29aDoc* pDoc = GetDocument();
    for (int i = 0; i < pDoc->m_nFields; i++) {
        var = m_pSet->GetFieldValue(i);
        switch (var.vt) {
        case VT_BSTR:
            str = (LPCSTR) var.bstrVal; // narrow characters in DAO
            break;
        case VT_I2:
            str.Format("%d", (int) var.iVal);
            break;
        case VT_I4:
            str.Format("%d", var.lVal);
            break;
        case VT_R4:
            str.Format("%10.2f", (double) var.fltVal);
            break;
        case VT_R8:
            str.Format("%10.2f", var.dblVal);
            break;
        case VT_CY:
            str = COleCurrency(var).Format();
            break;
        case VT_DATE:
            str = COleDateTime(var).Format();
            break;
        case VT_BOOL:
            str = (var.boolVal == 0) ? "FALSE" : "TRUE";
            break;
        case VT_NULL:
            str =  "----";
            break;
        default:
            str.Format("Unk type %d\n", var.vt);
            TRACE("Unknown type %d\n", var.vt);
        }
        pDC->TextOut(x, y, str);
        x += pDoc->m_arrayFieldSize[i] * m_nCharWidth;
    }
}
Ejemplo n.º 3
0
LPCTSTR COcsWmi::strVariant( VARIANT pVal)

{

	static CString strRet;



	strRet = _T( "N/A");

	switch(pVal.vt){

		case VT_EMPTY:

		case VT_NULL:

			strRet = _T( "");

			break;

		case VT_I1:

			strRet.Format(_T( "%hd"),V_I2(&pVal));

			break;

		case VT_I2:

			strRet.Format(_T( "%d"),V_I2(&pVal));

			break;

		case VT_I4:

			strRet.Format(_T( "%ld"),V_I4(&pVal));

			break;

		case VT_I8:

			strRet.Format(_T( "%I64d"), V_I8(&pVal));

			break; 

		case VT_UI1:

			strRet.Format(_T( "%hu"),V_UI1(&pVal));

			break;

		case VT_UI2:

			strRet.Format(_T( "%u"),V_UI2(&pVal));

			break;

		case VT_UI4:

			strRet.Format(_T( "%lu"),V_UI4(&pVal));

			break;

		case VT_UI8:

			strRet.Format(_T( "%I64u"),V_UI8(&pVal));

			break;

		case VT_INT:

			strRet.Format(_T( "%d"),V_INT(&pVal));

			break;

		case VT_UINT:

			strRet.Format(_T( "%u"),V_UINT(&pVal));

			break;

		case VT_R4:

			strRet.Format(_T( "%e"),V_R4(&pVal));

			break;

		case VT_R8:

			strRet.Format(_T( "%le"),V_R8(&pVal));

			break;

		case VT_CY:

			strRet = COleCurrency(pVal).Format();

			break;

		case VT_DATE:

			strRet = COleDateTime(pVal).Format( VAR_DATEVALUEONLY);

			break;

		case VT_BSTR:

			strRet = V_BSTRT(&pVal);

			break;

		case VT_DISPATCH:

			strRet = _T( "VT_DISPATCH");

			break;

		case VT_ERROR:

			strRet = _T( "VT_ERROR");

			break;

		case VT_BOOL:

			return (V_BOOL(&pVal) ? _T("TRUE") : _T("FALSE"));

		case VT_VARIANT:

			strRet = _T( "VT_VARIANT");

			break;

		case VT_UNKNOWN:

			strRet = _T( "VT_UNKNOWN");

			break;

		case VT_VOID:

			strRet = _T( "VT_VOID");

			break;

		case VT_HRESULT:

			strRet = _T( "VT_HRESULT");

			break;

		case VT_PTR:

			strRet = _T( "VT_PTR");

			break;

		case VT_SAFEARRAY:

			strRet = _T( "VT_SAFEARRAY");

			break;

		case VT_CARRAY:

			strRet = _T( "VT_CARRAY");

			break;

		case VT_USERDEFINED:

			strRet = _T( "VT_USERDEFINED");

			break;

		case VT_LPSTR:

			strRet = _T( "VT_LPSTR");

			break;

		case VT_LPWSTR:

			strRet = _T( "VT_LPWSTR");

			break;

		case VT_FILETIME:

			strRet = _T( "VT_FILETIME");

			break;

		case VT_BLOB:

			strRet = _T( "VT_BLOB");

			break;

		case VT_STREAM:

			strRet = _T( "VT_STREAM");

			break;

		case VT_STORAGE:

			strRet = _T( "VT_STORAGE");

			break;

		case VT_STREAMED_OBJECT:

			strRet = _T( "VT_STREAMED_OBJECT");

			break;

		case VT_STORED_OBJECT:

			strRet = _T( "VT_STORED_OBJECT");

			break;

		case VT_BLOB_OBJECT:

			strRet = _T( "VT_BLOB_OBJECT");

			break;

		case VT_CF:

			strRet = _T( "VT_CF");

			break;

		case VT_CLSID:

			strRet = _T( "VT_CLSID");

			break;

	}

	return strRet;

}
Ejemplo n.º 4
0
CString CCrack::strVARIANT(const COleVariant& var)
{
	CString strRet;
	strRet = _T("Fish");
	switch(var.vt){
		case VT_EMPTY:
		case VT_NULL:
			strRet = _T("NULL");
			break;
		case VT_I2:
			strRet.Format(_T("%hd"),V_I2(&var));
			break;
		case VT_I4:
			strRet.Format(_T("%d"),V_I4(&var));
			break;
		case VT_R4:
			strRet.Format(_T("%g"),(double)V_R4(&var));
			break;
		case VT_R8:
			strRet.Format(_T("%g"),V_R8(&var));
			break;
		case VT_CY:
			strRet = COleCurrency(var).Format();
			break;
		case VT_DATE:
			strRet = COleDateTime(var).Format(_T("%m %d %y"));
			break;
		case VT_BSTR:
			strRet = V_BSTRT(&var);
			break;
		case VT_DISPATCH:
			strRet = _T("VT_DISPATCH");
			break;
		case VT_ERROR:
			strRet = _T("VT_ERROR");
			break;
		case VT_BOOL:
			return strBOOL(V_BOOL(&var));
		case VT_VARIANT:
			strRet = _T("VT_VARIANT");
			break;
		case VT_UNKNOWN:
			strRet = _T("VT_UNKNOWN");
			break;
		case VT_I1:
			strRet = _T("VT_I1");
			break;
		case VT_UI1:
			strRet.Format(_T("0x%02hX"),(unsigned short)V_UI1(&var));
			break;
		case VT_UI2:
			strRet = _T("VT_UI2");
			break;
		case VT_UI4:
			strRet = _T("VT_UI4");
			break;
		case VT_I8:
			strRet = _T("VT_I8");
			break;
		case VT_UI8:
			strRet = _T("VT_UI8");
			break;
		case VT_INT:
			strRet = _T("VT_INT");
			break;
		case VT_UINT:
			strRet = _T("VT_UINT");
			break;
		case VT_VOID:
			strRet = _T("VT_VOID");
			break;
		case VT_HRESULT:
			strRet = _T("VT_HRESULT");
			break;
		case VT_PTR:
			strRet = _T("VT_PTR");
			break;
		case VT_SAFEARRAY:
			strRet = _T("VT_SAFEARRAY");
			break;
		case VT_CARRAY:
			strRet = _T("VT_CARRAY");
			break;
		case VT_USERDEFINED:
			strRet = _T("VT_USERDEFINED");
			break;
		case VT_LPSTR:
			strRet = _T("VT_LPSTR");
			break;
		case VT_LPWSTR:
			strRet = _T("VT_LPWSTR");
			break;
		case VT_FILETIME:
			strRet = _T("VT_FILETIME");
			break;
		case VT_BLOB:
			strRet = _T("VT_BLOB");
			break;
		case VT_STREAM:
			strRet = _T("VT_STREAM");
			break;
		case VT_STORAGE:
			strRet = _T("VT_STORAGE");
			break;
		case VT_STREAMED_OBJECT:
			strRet = _T("VT_STREAMED_OBJECT");
			break;
		case VT_STORED_OBJECT:
			strRet = _T("VT_STORED_OBJECT");
			break;
		case VT_BLOB_OBJECT:
			strRet = _T("VT_BLOB_OBJECT");
			break;
		case VT_CF:
			strRet = _T("VT_CF");
			break;
		case VT_CLSID:
			strRet = _T("VT_CLSID");
			break;
	}
	WORD vt = var.vt;
	if(vt & VT_ARRAY){
		vt = vt & ~VT_ARRAY;
		strRet = _T("Array of ");
	}
	if(vt & VT_BYREF){
		vt = vt & ~VT_BYREF;
		strRet += _T("Pointer to ");
	}
	if(vt != var.vt){
		switch(vt){
			case VT_EMPTY:
				strRet += _T("VT_EMPTY");
				break;
			case VT_NULL:
				strRet += _T("VT_NULL");
				break;
			case VT_I2:
				strRet += _T("VT_I2");
				break;
			case VT_I4:
				strRet += _T("VT_I4");
				break;
			case VT_R4:
				strRet += _T("VT_R4");
				break;
			case VT_R8:
				strRet += _T("VT_R8");
				break;
			case VT_CY:
				strRet += _T("VT_CY");
				break;
			case VT_DATE:
				strRet += _T("VT_DATE");
				break;
			case VT_BSTR:
				strRet += _T("VT_BSTR");
				break;
			case VT_DISPATCH:
				strRet += _T("VT_DISPATCH");
				break;
			case VT_ERROR:
				strRet += _T("VT_ERROR");
				break;
			case VT_BOOL:
				strRet += _T("VT_BOOL");
				break;
			case VT_VARIANT:
				strRet += _T("VT_VARIANT");
				break;
			case VT_UNKNOWN:
				strRet += _T("VT_UNKNOWN");
				break;
			case VT_I1:
				strRet += _T("VT_I1");
				break;
			case VT_UI1:
				strRet += _T("VT_UI1");
				break;
			case VT_UI2:
				strRet += _T("VT_UI2");
				break;
			case VT_UI4:
				strRet += _T("VT_UI4");
				break;
			case VT_I8:
				strRet += _T("VT_I8");
				break;
			case VT_UI8:
				strRet += _T("VT_UI8");
				break;
			case VT_INT:
				strRet += _T("VT_INT");
				break;
			case VT_UINT:
				strRet += _T("VT_UINT");
				break;
			case VT_VOID:
				strRet += _T("VT_VOID");
				break;
			case VT_HRESULT:
				strRet += _T("VT_HRESULT");
				break;
			case VT_PTR:
				strRet += _T("VT_PTR");
				break;
			case VT_SAFEARRAY:
				strRet += _T("VT_SAFEARRAY");
				break;
			case VT_CARRAY:
				strRet += _T("VT_CARRAY");
				break;
			case VT_USERDEFINED:
				strRet += _T("VT_USERDEFINED");
				break;
			case VT_LPSTR:
				strRet += _T("VT_LPSTR");
				break;
			case VT_LPWSTR:
				strRet += _T("VT_LPWSTR");
				break;
			case VT_FILETIME:
				strRet += _T("VT_FILETIME");
				break;
			case VT_BLOB:
				strRet += _T("VT_BLOB");
				break;
			case VT_STREAM:
				strRet += _T("VT_STREAM");
				break;
			case VT_STORAGE:
				strRet += _T("VT_STORAGE");
				break;
			case VT_STREAMED_OBJECT:
				strRet += _T("VT_STREAMED_OBJECT");
				break;
			case VT_STORED_OBJECT:
				strRet += _T("VT_STORED_OBJECT");
				break;
			case VT_BLOB_OBJECT:
				strRet += _T("VT_BLOB_OBJECT");
				break;
			case VT_CF:
				strRet += _T("VT_CF");
				break;
			case VT_CLSID:
				strRet += _T("VT_CLSID");
				break;
		}
	}
	return strRet;
}