VC++ Win7关闭UAC 写注册表

#define STR_REGUAC_PATH  "SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Policies\\System"


void CloseUAC()
{
HKEY   RegKey; 
RegKey=NULL;   
RegOpenKey(HKEY_LOCAL_MACHINE,STR_REGUAC_PATH,&RegKey);  
    DWORD dwNum = 0;


RegSetValueEx(RegKey, _T("ConsentPromptBehaviorAdmin"), 0, REG_DWORD, (LPBYTE)&dwNum, sizeof(dwNum)); 

RegSetValueEx(RegKey, _T("EnableLUA"), 0, REG_DWORD, (LPBYTE)&dwNum, sizeof(dwNum)); 


RegSetValueEx(RegKey, _T("PromptOnSecureDesktop"), 0, REG_DWORD, (LPBYTE)&dwNum, sizeof(dwNum)); 


RegCloseKey( RegKey);


}



//#define  STR_REG_PATH  "SOFTWARE\\Microsoft\\Windows NT\\CurrentVersion\\Winlogon\\ Userinit"  
#define STR_REG_PATH  "SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Run"


void RegAuto(BOOL bAuto)
{
CRegKey  key;
key.RegOpen(HKEY_CURRENT_USER,STR_REG_PATH);
CString str(SfxGetModulePath(NULL));
CString strTmp = "Win7Test.exe";
if (bAuto)
str = str + "\\" + strTmp;
else
str = "";

strTmp = "Win7Test";
key.RegWrite(strTmp,str);
key.RegClose();
}

你可能感兴趣的:(VC++ Win7关闭UAC 写注册表)