Home > Back-end >  Win8.1 VS2012 ascension registry permissions (run as administrator)
Win8.1 VS2012 ascension registry permissions (run as administrator)

Time:10-01

I want to run the program directly to the average user account, but return to 5 res, check information, insufficient permissions, if the right click, to run as "administrator", can be successful, the following is the code
 EnableDebugPriv (); 
Hkeys hkeys;
DWORD KeyValue=https://bbs.csdn.net/topics/4;
Cstrings strRegPath=_T (SYSTEM \ \ CurrentControlSet \ \ Services \ \ "USBSTOR");//find the system startup
LONG res;
Res=RegOpenKeyEx (HKEY_LOCAL_MACHINE, strRegPath, 0, KEY_ALL_ACCESS, & amp; Hkeys);
If (bUSBDrive)
{
If (res==ERROR_SUCCESS)
{
RegSetValueEx (hkeys, _T (" Start "), and 0, REG_DWORD, (LPBYTE) & amp; KeyValue, sizeof (DWORD));
RegCloseKey (hkeys);
MessageBox (_T (" disable U disk drive success!" ));
}
The else
{
MessageBox (_T (" disable U disk drive failure!" ));

}
}
The else
{
KeyValue=https://bbs.csdn.net/topics/3;
If (res==ERROR_SUCCESS)
{
RegSetValueEx (hkeys, _T (" Start "), and 0, REG_DWORD, (LPBYTE) & amp; KeyValue, sizeof (DWORD));
RegCloseKey (hkeys);
MessageBox (_T (" load U disk drive success!" ));
}
The else
{
MessageBox (_T (" load U disk drive failure!" ));
}
}
  • Related