vc 获取 硬盘序列号 和 cpu 唯一iD的方法?
如题---------网上找来很多资料 也没找到, 要支持xp win7 32/64 系统下都能获取 硬盘序列号 和cpu ID 哪位朋友帮帮忙;
------解决方案--------------------
不是很确定 没有测试64位的 http://blog.sina.com.cn/s/blog_612b382d0100efdt.html
------解决方案--------------------
CString cpu_id()
{
int s1,s2;
CString CPUID_1,CPUID_2;
__asm{
mov eax,01h
xor edx,edx
cpuid
mov s1,edx
mov s2,eax
}
CPUID_1.Format("%08X%08X",s1,s2);
__asm{
mov eax,03h
xor ecx,ecx
xor edx,edx
cpuid
mov s1,edx
mov s2,ecx
}
CPUID_2.Format("%08X%08X",s1,s2);
return CPUID_1+CPUID_2;
}
CString disk_id()
{
CString id;
char Name[MAX_PATH];
DWORD serno;
DWORD length;
DWORD FileFlag;
char FileName[MAX_PATH];
BOOL Ret;
Ret = GetVolumeInformation("c:\\", Name, MAX_PATH,
&serno, &length, &FileFlag, FileName, MAX_PATH);
if (Ret)
id.Format( "%x", serno);
return id;
}
CString computer_id()
{
static CString cid;
if (cid.IsEmpty()) {
CString cpu_disk = cpu_id() + disk_id();
cid = cpu_disk;
//CMD5Checksum md5;
//const char* pcd = cpu_disk;
//cid = md5.GetMD5( (BYTE*)pcd, cpu_disk.GetLength());
}
return cid;
}
------解决方案--------------------
cpu序列号好像是取不到的