Jeg stjal lidt kode herfra:
http://www.codeproject.com/system/PIIISN.aspOg skrev det lidt om så det kan kompileres med Borland (kræver at du sætter kompileren til at kompilere til Pentium):
#include <string>
#include <iostream>
#include <windows>
void GetProcessorSeialNumbet(bool withSeparator)
{
DWORD t,m,b; //top,middle,botttom
DWORD serial[3];
_asm {
mov eax,1
cpuid
mov t,eax
mov eax,3
cpuid
mov m,edx
mov b,ecx
}
// copy the locals into the pointer variables passed in
serial[0] = b;
serial[1] = m;
serial[2] = t;
std::string temp;
std::string Serial;
static char hex_chars[16] = {'0','1','2','3','4','5','6','7', '8','9','A','B','C','D','E','F'};
for (int dw_count = 2; dw_count>=0; dw_count--)
{
for (int bp = 28; bp >= 0; bp-=4)
{
DWORD nibble = (serial[dw_count] >> bp) & 0x0f;
Serial += hex_chars[nibble];
if ((bp == 16) || ((bp == 0) && (dw_count!=0)))
if(withSeparator)
Serial += "-";
}
}
std::cout << "Serial: " << Serial << std::endl;
}
int main()
{
GetProcessorSeialNumbet(true);
}