C ++ WMI UINT64问题 [英] C++ WMI UINT64 question

查看:122
本文介绍了C ++ WMI UINT64问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个WMI类,并且我读得很好,我有几个读取属性的小functins.显然每个属性都有不同的属性类型.

我的问题是,您将用什么来阅读uint64?

对于字符串:

I have a WMI class and im reading fine, I have a couple of small functins that read properties. Obviously each will have a different property type.

My question is what would you use to read the uint64?

For Strings:

void WMIReader::ReadPropertyString( WCHAR* PropertyName, char* ReturnBuffer )
{
	VARIANT pProperty;
	ClassObject->Get( PropertyName, 0, &pProperty, 0, 0 );
	sprintf( ReturnBuffer, "%S", pProperty.bstrVal ); //bstrVal for strings
	VariantClear( &pProperty );
}



对于整数:



For Integers:

void WMIReader::ReadPropertyInt( WCHAR* PropertyName, char* ReturnBuffer )
{
	VARIANT pProperty;
	ClassObject->Get( PropertyName, 0, &pProperty, 0, 0 );
	sprintf( ReturnBuffer, "%i", pProperty.intVal ); //intVal for integers
	VariantClear( &pProperty );
}



对于UINT64:



For UINT64:

void WMIReader::ReadPropertyInt( WCHAR* PropertyName, char* ReturnBuffer )
{
    VARIANT pProperty;
    ClassObject->Get( PropertyName, 0, &pProperty, 0, 0 );
    sprintf( ReturnBuffer, "%i", pProperty.???? ); //What for uint64?
    VariantClear( &pProperty );
}



感谢



Thanks

推荐答案

确定,您将使用该字符串读取uint64值.我运行wbemtest,查询我的硬盘是否找到了大小值(如果您随后编辑该属性,它告诉您限定符为"CIMTYPE CIM_STRING uint64").

我对此进行了测试,并使用字符串读取器查询了大小,并得到了:

硬盘:[C:\]-大小:[1000202039296]

与Windows显示的1,000,202,039,296字节相匹配.将其除以1024得到976759804 KB.将其除以1024得到953866 MB.将其除以1024得到931 GB.

因此,对于其他想要阅读uint64的人,请使用bStrVal(字符串).
Ok turns out you would use the string to read a uint64 value. I ran wbemtest, queried my hard disk found the size value if you then edit the property it tells you the qualifier is "CIMTYPE CIM_STRING uint64".

I put this to the test and queried the size using the string reader and got:

Hard Disk: [C:\] - Size: [1000202039296]

Which matches what windows shows me as 1,000,202,039,296 bytes. Divide that by 1024 to get 976759804 KB. Divide that by 1024 to get 953866 MB. Divide that by 1024 to get 931 GB.

So for others wanting to read a uint64 use the bStrVal (String).


Aah,您需要参考文档.

在这里您可以 http://msdn.microsoft.com/en-us/library/ms221627(v = vs.85) [ ^ ]

艾伦.
Aah, you need a reference to the documentation.

Here you go http://msdn.microsoft.com/en-us/library/ms221627(v=vs.85)[^]

Alan.


你好,看着 ^ ]我的猜测是ullVal

即sizeof(unsigned long long)= 8(win7 32bit应用程序)
Hi there, looking at VARIANT structure[^] my guess would be ullVal

I.e sizeof(unsigned long long) = 8 (win7 32bit app)


这篇关于C ++ WMI UINT64问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆