完整的硬盘序列在非管理员模式下无法获取Windows7/Vista [英] full Hard Disc serial not getting windows7/vista in non admin mode
问题描述
首先,我对Windows的用户身份验证系统一无所知.
我正在尝试获取HDD序列号以用于用户身份验证
它工作正常,但是如果我在没有管理员权限的情况下运行exe,则在win 7或Vista中是一个很好的选择
我没有完整的序列号.只有一半的序列号要来.[因为硬盘编号由两部分组成]
我想知道为什么会这样吗?还是有没有管理员权限的方法.
[如果最好使用vc ++中的代码,否则对我来说java中的代码也可以]
请帮我. :(
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. :(
推荐答案
AFAIK,没有不以管理模式运行"获得序列号的解决方法.
AFAIK, there is no workaround for getting the serial no without "running in admin mode".
非常感谢您的答复.但是我有一点疑问.
由于我对此没有详细的了解. :(
1>为什么不允许HDD序列号?您可以给我任何与此相关的链接吗?
2>我可以通过下面的代码获取处理器ID
即使在没有管理员权限的管理模式下也是如此.
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; //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+="-";
}
}
}
操作系统ID相同.
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",// YOUR value
NULL,&type,(LPBYTE)&res[0],&size);
RegCloseKey(key);
csData.Format("%s",res);
}
}
为什么会这样?
why so?
这篇关于完整的硬盘序列在非管理员模式下无法获取Windows7/Vista的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!