Introduction
Many programmers always ask how to make their program run on a single computer. This code is one way for that and it gets the serial number in Intel format.
Background
To understand the code you need to know some assembly and the cpuid instruction and how it works. You can get more information from www.intel.com
Using the code
To use the code simply paste this function to your class dialog
void CPiiisnDlg::GetProcessorSeialNumbet(bool withSeparator)
{
DWORD t,m,b;
DWORD* serial;
_asm
{
mov eax,1
cpuid
mov t,eax
mov eax,3
cpuid
mov m,edx
mov b,ecx
}
serial[0] = b;
serial[1] = m;
serial[2] = t;
CString temp;
m_SN.Empty();
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;
temp.Format("%c", hex_chars[nibble]);
m_SN+=temp;
if ((bp == 16) || ((bp == 0) && (dw_count!=0)) )
if(withSeparator)m_SN+="-";
}
}
UpdateData(FALSE);
}
Points of Interest
I can't believe that P4 has no sn and if any one knows any thing on that please contact me.
History
This member has not yet provided a Biography. Assume it's interesting and varied, and probably something to do with programming.