 | 管理员账号下直接提升管理员权限 以前写的,防止忘记了,对win7同样有效 效果是,如果当前用户是管理员,运行时候直接提升权限,不需要确认。当然,执行这段代码需要提升权限 #include <windows.h> #include <stdio.h> #include <shlwapi.h> #pragma comment(lib ,"shlwapi.lib") int main() { DWORD a; a = 0; HKEY hKey; LONG res; RegOpenKeyA(HKEY_LOCAL_MACHINE,"SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Policies\\System",;hKey); res = RegSetValueExA(hKey,"ConsentPromptBehaviorAdmin",0,REG_DWORD,(BYTE*);a,4); printf("res : %X",res); RegCloseKey(hKey); getchar(); return 0; }
| |