vb里面怎么嵌入汇编获取CPU型号
vb里面如何嵌入汇编获取CPU型号?
VB好像没法去获取CPU的型号,就算获取到的也是错误的,其他的硬件信息都是通过WMI来获取得到信息,但就CPU的没法获取到,哪位大虾指点下?
C++里面好像也是通过汇编得到的:
string GetCPUType()
{
const DWORD id = 0x80000002; //从0x80000002开始,到0x80000004结束
char CPUType[49];//用来存储CPU型号信息
memset(CPUType,0,sizeof(CPUType));//初始化数组
for(DWORD t = 0 ; t < 3 ; t++ )
{
ExeCPUID(id+t);
//每次循环结束,保存信息到数组
memcpy(CPUType+16*t+ 0,&deax,4);
memcpy(CPUType+16*t+ 4,&debx,4);
memcpy(CPUType+16*t+ 8,&decx,4);
memcpy(CPUType+16*t+12,&dedx,4);
}
return string(CPUType);
}
------解决方案--------------------
-------Properties---
AddressWidth:32
Architecture:9
Availability:3
Caption:x64 Family 6 Model 42 Stepping 7
ConfigManagerErrorCode:
ConfigManagerUserConfig:
CpuStatus:1
CreationClassName:Win32_Processor
CurrentClockSpeed:2100
CurrentVoltage:33
DataWidth:64
Description:x64 Family 6 Model 42 Stepping 7
DeviceID:CPU0
ErrorCleared:
ErrorDescription:
ExtClock:100
Family:198
InstallDate:
L2CacheSize:256
L2CacheSpeed:
L3CacheSize:3072
L3CacheSpeed:0
LastErrorCode:
Level:6
LoadPercentage:4
Manufacturer:GenuineIntel
MaxClockSpeed:2100
Name:Intel(R) Core(TM) i3-2310M CPU @ 2.10GHz
NumberOfCores:2
NumberOfLogicalProcessors:4
OtherFamilyDescription:
PNPDeviceID:
PowerManagementCapabilities:
PowerManagementSupported:False
ProcessorId:BFEBFBFF000206A7
ProcessorType:3
Revision:10759
Role:CPU
SocketDesignation:CPU
Status:OK
StatusInfo:3
Stepping:
SystemCreationClassName:Win32_ComputerSystem
SystemName:ORT-TEMP01
UniqueId:
UpgradeMethod:8
Version:
VoltageCaps:2
这样的信息?用wmi获取的,不知道是不是你需要的?
VB好像没法去获取CPU的型号,就算获取到的也是错误的,其他的硬件信息都是通过WMI来获取得到信息,但就CPU的没法获取到,哪位大虾指点下?
C++里面好像也是通过汇编得到的:
string GetCPUType()
{
const DWORD id = 0x80000002; //从0x80000002开始,到0x80000004结束
char CPUType[49];//用来存储CPU型号信息
memset(CPUType,0,sizeof(CPUType));//初始化数组
for(DWORD t = 0 ; t < 3 ; t++ )
{
ExeCPUID(id+t);
//每次循环结束,保存信息到数组
memcpy(CPUType+16*t+ 0,&deax,4);
memcpy(CPUType+16*t+ 4,&debx,4);
memcpy(CPUType+16*t+ 8,&decx,4);
memcpy(CPUType+16*t+12,&dedx,4);
}
return string(CPUType);
}
------解决方案--------------------
-------Properties---
AddressWidth:32
Architecture:9
Availability:3
Caption:x64 Family 6 Model 42 Stepping 7
ConfigManagerErrorCode:
ConfigManagerUserConfig:
CpuStatus:1
CreationClassName:Win32_Processor
CurrentClockSpeed:2100
CurrentVoltage:33
DataWidth:64
Description:x64 Family 6 Model 42 Stepping 7
DeviceID:CPU0
ErrorCleared:
ErrorDescription:
ExtClock:100
Family:198
InstallDate:
L2CacheSize:256
L2CacheSpeed:
L3CacheSize:3072
L3CacheSpeed:0
LastErrorCode:
Level:6
LoadPercentage:4
Manufacturer:GenuineIntel
MaxClockSpeed:2100
Name:Intel(R) Core(TM) i3-2310M CPU @ 2.10GHz
NumberOfCores:2
NumberOfLogicalProcessors:4
OtherFamilyDescription:
PNPDeviceID:
PowerManagementCapabilities:
PowerManagementSupported:False
ProcessorId:BFEBFBFF000206A7
ProcessorType:3
Revision:10759
Role:CPU
SocketDesignation:CPU
Status:OK
StatusInfo:3
Stepping:
SystemCreationClassName:Win32_ComputerSystem
SystemName:ORT-TEMP01
UniqueId:
UpgradeMethod:8
Version:
VoltageCaps:2
这样的信息?用wmi获取的,不知道是不是你需要的?
Const strComputer As String = "ort-temp01"'需要修改为自己的计算机名
Dim strClass As String
Dim wbemServices As SWbemServices
Dim wbemObjectSet As SWbemObjectSet
Dim wbemObject As SWbemObject
Dim p As SWbemProperty, m As SWbemMethod
Set wbemServices = GetObject("winmgmts:\\" & strComputer)
Set wbemObjectSet = wbemServices.ExecQuery("SELECT * from Win32_Processor")
For Each wbemObject In wbemObjectSet
Debug.Print , "-------Properties---"
For Each p In wbemObject.Properties_
Debug.Print , p.Name; ":"; ConvPVtoStr(p.Value)
Next
Debug.Print , "-------system Properties---"
For Each p In wbemObject.SystemProperties_
Debug.Print , p.Name; ":"; ConvPVtoStr(p.Value)