见如下代码,经过验证,是可行的。
static const char* cpuId(void)
{
unsigned long s1 = 0;
unsigned long s2 = 0;
unsigned long s3 = 0;
unsigned long s4 = 0;
__asm
{
mov eax,00h
xor edx,edx
cpuid
mov s1, edx
mov s2, eax
}
__asm
{
mov eax,01h
xor ecx,ecx
xor edx,edx
cpuid
mov s3, edx
mov s4, ecx
}
static char buf[100];
sprintf(buf, "%08X%08X%08X%08X", s1, s2, s3, s4);
return buf;
}
本文介绍了一种使用汇编语言从CPU中获取唯一标识符的方法。通过两段汇编代码,分别调用不同的指令来收集CPU信息,并将其转换为字符串形式返回。这种方法可用于识别不同类型的CPU。

2807

被折叠的 条评论
为什么被折叠?



