Hi ,Thanks a lot for reply.But I have a little doubt.
As I don't have detailed knowledge on this. :(
1>why it is not allowing HDD serial no? can you give me any link regarding this?
2>I can get processor ID by the code below
even in admin mode without admin privilege.
void CPxMachineCode::GetProcessorSerialNumber(CString &csData,BOOL withSeparator)
{
DWORD t,b;
DWORD serial[2];
_asm
{
mov eax,1
cpuid
mov t,eax
mov b,edx
}
serial[0] = t;
serial[1] = b;
CString temp;
csData.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 = 1; 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]);
csData+=temp;
if ((bp == 16) || ((bp == 0) && (dw_count!=0)) )
if(withSeparator)csData+="-";
}
}
}
same for OS id.
void CPxMachineCode::GetOSId(CString& csData)
{
unsigned long type=REG_SZ, size=1024;
char res[1024]="";
HKEY key;
if (RegOpenKeyEx(HKEY_LOCAL_MACHINE, "SOFTWARE\\Microsoft\\Windows NT\\CurrentVersion",NULL, KEY_READ, &key)==ERROR_SUCCESS)
{
RegQueryValueEx(key,
"ProductID",
NULL,&type,(LPBYTE)&res[0],&size);
RegCloseKey(key);
csData.Format("%s",res);
}
}
why so?