BorlandTalk.com Forum Index BorlandTalk.com
Borland discussion newsgroups
 
Archives   FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Variant conversion of CIM: CIM_UINT64

 
Post new topic   Reply to topic    BorlandTalk.com Forum Index -> C++ Builder (Language C++)
View previous topic :: View next topic  
Author Message
Maurice Anderson
Guest





PostPosted: Tue Aug 02, 2005 6:53 am    Post subject: Variant conversion of CIM: CIM_UINT64 Reply with quote



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





PostPosted: Tue Aug 02, 2005 4:52 pm    Post subject: Re: Variant conversion of CIM: CIM_UINT64 Reply with quote




"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
Display posts from previous:   
Post new topic   Reply to topic    BorlandTalk.com Forum Index -> C++ Builder (Language C++) All times are GMT
Page 1 of 1

 
Jump to:  
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


Powered by phpBB © 2001, 2006 phpBB Group
SEO toolkit © 2004-2006 webmedic.