vb里面如何嵌入汇编获取CPU型号?
本帖最后由 seal520 于 2013-06-19 16:22:39 编辑 ExeCPUID这个函数的函数体是什么? GetCPUType 放到.dll 中给VB调用最简单 通过注册表来得到CPU信息吧。这样容易得多。
这个方法行不通
注册表中有CPU信息的啊。 用C++写一个dll,让VB调用。
嵌入cpuid指令。通过传不同的eax值,可以获得CPU Vendor、BrandString、特性掩码、扩展特性掩码等信息。
http://en.易做图.org/wiki/CPUID
如果你觉得麻烦,也可以调用一个叫Coreinfo的程序,http://technet.microsoft.com/en-us/sysinternals/cc835722,你可以让它输出结果到一个文本文件,然后装入读取结果。
10001000 . 8B4424 08 MOV EAX,DWORD PTR SS:[ESP+8]
10001004 . 0FA2 CPUID
10001006 . 8B7424 04 MOV ESI,DWORD PTR SS:[ESP+4]
1000100A . 8906 MOV DWORD PTR DS:[ESI],EAX
1000100C . 895E 04 MOV DWORD PTR DS:[ESI+4],EBX
1000100F . 894E 08 MOV DWORD PTR DS:[ESI+8],ECX
10001012 . 8956 0C MOV DWORD PTR DS:[ESI+C],EDX
10001015 . C2 0800 RETN 8
这点东西用callwindowproc执行了试试
sub getcpuid (ID,Result)
end sub
这是这么个东西, result 是个传址参数,接收cpuid的数据,一共16个字节
-------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)
Next
Debug.Print , "-------Method---"
For Each m In wbemObject.Methods_
Debug.Print , m.Name,
Next
Debug.Print ,
Next
Function ConvPVtoStr(PropertyValue As Variant)学习了,标记下。
If IsObject(PropertyValue) Then
ConvPVtoStr = ""
ElseIf IsNull(PropertyValue) Then
ConvPVtoStr = ""
ElseIf IsArray(PropertyValue) Then
ConvPVtoStr = Join(PropertyValue, ",")
Else
ConvPVtoStr = CStr(PropertyValue)
End If
End Function
Environ("PROCESSOR_IDENTIFIER")试试这个,最easy的 奉劝楼主不要把有限的生命浪费在无限的加密解密死循环中!
Environ("PROCESSOR_REVISION")
Environ("PROCESSOR_ARCHITECTURE")
补充:VB , API