开发者

How do I get hardware info such as CPU name, total RAM, etc. with VB6?

Title pretty much explains it all. I need to get some hardware information such as CPU info, and total RAM with VB6. Ideally, it would return something l开发者_运维技巧ike this for the CPU:

Intel Core 2 Quad Q8500 2.66 GHz

and for the RAM something simple like an integer for the amount of MB the computer has total.


in plain C, if interested:

#include <intrin.h>

int cpuInfo[4] = {-1};
char CPUBrandString[0x40];

memset(CPUBrandString, 0, sizeof(CPUBrandString));

__cpuid(cpuInfo, 0x80000002);
memcpy(CPUBrandString, cpuInfo, sizeof(cpuInfo));

__cpuid(cpuInfo, 0x80000003);
memcpy(CPUBrandString + 16, cpuInfo, sizeof(cpuInfo));

__cpuid(cpuInfo, 0x80000004);
memcpy(CPUBrandString + 32, cpuInfo, sizeof(cpuInfo));


You could use WMI to get this information: http://msdn.microsoft.com/en-us/library/aa394084(v=VS.85).aspx

This information is also available in the registry (if WMI isn't to your liking): HKLM/HARDWARE/DESCRIPTION/System/CentralProcessor

NOTE: Registry keys and locations may change. The WMI API is designed as a more stable source for this kind of information.


RAM - GetPhysicallyInstalledSystemMemory (GlobalMemoryStatusEx on earlier versions)

CPU - GetSystemInfo (not in the desired friendly form, I'm afraid). There is a very extensive discussion of more detailed CPU info retrieval here.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜