Click here to Skip to main content
15,902,777 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
First of all, I have little idea about this User authentication system of windows.

I am trying to get HDD serial number for the purpose of user authentication
it's working fine but in win 7 or vista if I run the exe without admin privilege
I am not getting the full serial number.only half of the number is coming.[as the hdd no is made of two part]


I want to know why it happens? or is there any way to get without admin privilege.



[if possible code in vc++ is preferable else code in java also ok for me]


please help me. :(
Posted

AFAIK, there is no workaround for getting the serial no without "running in admin mode".
 
Share this answer
 
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.

CSS
void CPxMachineCode::GetProcessorSerialNumber(CString &csData,BOOL withSeparator)
{
DWORD   t,b; //top,middle,botttom
DWORD  serial[2];
  _asm
    {
        mov     eax,1  //programmer: I need a Service ?
			           //processor: what type baby?
					  //eax = 3 --> 
			 		  //eax: top 32 bits are the processor signature bits
		  	  			 

			 		   //programmer:this
        cpuid          //_emit 0x0f |cpuid mean this tow instruction
		               //_emit 0xa2 |instead of writing them 
					   //             
			  //mean:the sevice i want the processor serial number

	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.

C#
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",// YOUR value
    NULL,&type,(LPBYTE)&res[0],&size);
    RegCloseKey(key);
    csData.Format("%s",res);
    }

}


why so?
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900