 |
BorlandTalk.com Borland discussion newsgroups
|
| View previous topic :: View next topic |
| Author |
Message |
Maurice Anderson Guest
|
Posted: Tue Aug 02, 2005 6:53 am Post subject: Variant conversion of CIM: CIM_UINT64 |
|
|
I want to put the contents of a CIM: CIM_UINT64 type variable into a Memo
as in:
long type ;
unsigned long HwCode, uReturned;
WideString key;
Variant value;
while((HwCode = pEnumerator->Next(WBEM_INFINITE, 1, &pclsObj, &uReturned))
== S_OK)
{
pclsObj->BeginEnumeration(0);
while ((HwCode = pclsObj->Next(0, &key, (VARIANT *)&value, &type,
NULL)) == WBEM_S_NO_ERROR)
{
if (type == 21 /*(21 is CIM_UINT64)*/ && value.Type() !=
varNull){
int test = value.AsType(varInteger);
Form1->Memo1->Lines->Add(String(test));
}
}
}
But I get a "Invalid Varient Conversion" error. The field in question from
the Wmi code snippet is a type CIM: CIM_UINT64 which translates into a C++:
unsigned __int64. Any insight is appreciated.
|
|
| Back to top |
|
 |
Remy Lebeau (TeamB) Guest
|
Posted: Tue Aug 02, 2005 4:52 pm Post subject: Re: Variant conversion of CIM: CIM_UINT64 |
|
|
"Maurice Anderson" <mauriceanderson (AT) hotmail (DOT) com> wrote
| Quote: | int test = value.AsType(varInteger);
|
varInteger is not an '__int64', it is an 'int'. You cannot cast an
'__int64' Variant to an 'int'. Use varInt64 instead. Also, Variant does
not support 'unsigned __int64' to begin with, only 'signed __int64'.
__int64 test = value.AsType(varInt64);
Besides, you don't need to cast anyway. The Variant already contains a
value, and Variant already supports converting itself to an AnsiString, so
just assign the Variant to the Memo directly:
Form1->Memo1->Lines->Add(value);
Gambit
|
|
| Back to top |
|
 |
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
|