1 // 提升升级工具进程权限为SE_DEBUG_NAME,否则XP下无法杀掉进程 2 HANDLE hToken = NULL; 3 if(OpenProcessToken(GetCurrentProcess(), TOKEN_ALL_ACCESS, &hToken)) 4 { 5 LUID luid; 6 if(LookupPrivilegeValue(NULL, SE_DEBUG_NAME, &luid)) 7 { 8 TOKEN_PRIVILEGES TokenPrivileges; 9 TokenPrivileges.PrivilegeCount = 1; 10 TokenPrivileges.Privileges[0].Attributes = SE_PRIVILEGE_ENABLED; 11 TokenPrivileges.Privileges[0].Luid = luid; 12 AdjustTokenPrivileges(hToken, FALSE, &TokenPrivileges, 0, NULL, NULL); 13 } 14 CloseHandle(hToken); 15 }