VB6如何获取电脑的CPU序号?

VB6如何获取电脑的CPU序号?另外,CPU序号不会重复吧?我想让程序自己标识出电脑来。... VB6如何获取电脑的CPU序号?另外,CPU序号不会重复吧?
我想让程序自己标识出电脑来。
展开
 我来答
残指乱谭
2009-02-06 · TA获得超过3729个赞
知道大有可为答主
回答量:2983
采纳率:0%
帮助的人:940万
展开全部
1、API里有相关函数

2、VB取CPU信息源代码:

Private Declare Function RegCreateKey Lib "advapi32.dll" Alias "RegCreateKeyA" (ByVal hKey As Long, ByVal lpSubKey As String, phkResult As Long) As Long
Private Declare Function RegSetValueEx Lib "advapi32.dll" Alias "RegSetValueExA" (ByVal hKey As Long, ByVal lpValueName As String, ByVal Reserved As Long, ByVal dwType As Long, lpData As Any, ByVal cbData As Long) As Long
Private Declare Function RegQueryValueEx Lib "advapi32.dll" Alias "RegQueryValueExA" (ByVal hKey As Long, ByVal lpValueName As String, ByVal lpReserved As Long, lpType As Long, lpData As Any, lpcbData As Long) As Long
Private Declare Function RegOpenKey Lib "advapi32.dll" Alias "RegOpenKeyA" (ByVal hKey As Long, ByVal lpSubKey As String, phkResult As Long) As Long
Const REG_SZ = 1
Const REG_DWORD = 4
Const HKEY_CURRENT_USER = &H80000001
Const HKEY_LOCAL_MACHINE = &H80000002
Private Sub Command1_Click()
Dim cpupl As String * 100
Dim ret As Long, hKey&
ret = RegOpenKey(HKEY_LOCAL_MACHINE, "HARDWARE\DESCRIPTION\System\CentralProcessor\0", hKey)
RegQueryValueEx hKey, "ProcessorNameString", 0, REG_SZ, ByVal cpupl, Len(cpupl)
'cpuinfo = Left(cpupl, InStr(cpupl, Chr(0)) - 1)
MsgBox cpupl
End Sub
鑫曼苹薇
2015-12-13 · 超过11用户采纳过TA的回答
知道答主
回答量:71
采纳率:100%
帮助的人:51.9万
展开全部
获取CPU序列号要使用 汇编指令

比较麻烦

static DWORD g_eax; // 存储返回的eax
static DWORD g_ebx; // 存储返回的ebx
static DWORD g_ecx; // 存储返回的ecx
static DWORD g_edx; // 存储返回的edx

void Executecpuid(DWORD veax)
{
asm("cpuid"
:"=a"(g_eax),
"=b"(g_ebx),
"=c"(g_ecx),
"=d"(g_edx)
:"a"(g_eax));
}
int isSupport;
void GetSerialNumber(WORD nibble[6])
{
Executecpuid(1); // 执行cpuid,参数为 eax = 1
isSupport = g_edx & (1<<18); // edx是否为1代表CPU是否存在序列号
if (FALSE == isSupport) // 不支持,返回false
{
return ;
}
Executecpuid(3); // 执行cpuid,参数为 eax = 3
memcpy(&nibble[4], &g_eax, 4); // eax为最高位的两个WORD
memcpy(&nibble[0], &g_ecx, 8); // ecx 和 edx为低位的4个WORD
本回答被网友采纳
已赞过 已踩过<
你对这个回答的评价是?
评论 收起
收起 1条折叠回答
推荐律师服务: 若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询

为你推荐:

下载百度知道APP,抢鲜体验
使用百度知道APP,立即抢鲜体验。你的手机镜头里或许有别人想知道的答案。
扫描二维码下载
×

类别

我们会通过消息、邮箱等方式尽快将举报结果通知您。

说明

0/200

提交
取消

辅 助

模 式