获得CPU-ID(序列号、机器码)的C++代码源码

52 阅读1分钟

本篇文章属于《518抽奖软件开发日志》系列文章的一部分。

本篇文章属于《518抽奖软件开发日志》系列文章的一部分。

我在开发《518抽奖软件》(www.518cj.net)的时候,在软件的注册部分,需要获得CPU的序列号(ID/机器码)。在网上找了一…

` unsigned long a = 0;

unsigned long d = 0;

__asm

{

mov eax, 01h

xor edx, edx

cpuid

mov d, edx

mov a, eax

};

 

char s[256] = { 0 };

sprintf(s, "%08X%08X", d, a);

unsigned int hashcode = Tfuns::ELFHash((unsigned char*)s, strlen(s));

unsigned int cpuid = hashcode % 1000; ` 主要通过上面的汇编指令,然后经过hash运算可以缩小序列号的长度。