/* Simple code to turn off a WindowsXP based computer. Wednesday 7 Feb, 2007 - Simon (enhzflep) Based on code by Greg Van Loon - author of StartupManager */ #include <windows.h> void EnableShutdownPrivileges() { HANDLE token; TOKEN_PRIVILEGES privileges; if(!::OpenProcessToken(GetCurrentProcess(), TOKEN_ADJUST_PRIVILEGES | TOKEN_QUERY, &token)) ::MessageBox(NULL, "ERROR: Unable to open process token.", "Error", MB_OK | MB_ICONERROR); ::LookupPrivilegeValue(NULL, SE_SHUTDOWN_NAME, &privileges.Privileges[0].Luid); privileges.PrivilegeCount = 1; privileges.Privileges[0].Attributes = SE_PRIVILEGE_ENABLED; ::AdjustTokenPrivileges(token, FALSE, &privileges, 0, (PTOKEN_PRIVILEGES)NULL, 0); if(::GetLastError() != ERROR_SUCCESS) ::MessageBox(NULL, "ERROR: Uanble to adjust token privileges.", "Error", MB_OK | MB_ICONERROR); } int APIENTRY WinMain(HINSTANCE _1,HINSTANCE _2,LPSTR _3,int _4) { EnableShutdownPrivileges(); ExitWindowsEx(EWX_SHUTDOWN, 0); return 1; }
ICON1 ICON "G:\\PowerOff.ico" 1 VERSIONINFO FILEVERSION 2,0,0,1 PRODUCTVERSION 2,0,0,1 BEGIN BLOCK "StringFileInfo" BEGIN BLOCK "040904E4" BEGIN VALUE "Comments", "This is a program designed to shut down Windows.\0" VALUE "Description", "Enhzflep 2007\0" VALUE "FileVersion", "1.0.0.1" VALUE "FileDescription", "Shuts down Windows\0" VALUE "InternalName", "PowerOff\0" VALUE "LegalCopyright", "Copyright \xA9 2007, Enhzflep\0" VALUE "OriginalFilename", "PowerOff.EXE\0" VALUE "ProductName", "PowerOff 1.1\0" VALUE "ProductVersion", "1.0.0.1\0" VALUE "License", "None Needed\0" END END BLOCK "VarFileInfo" BEGIN VALUE "Translation", 0x0409, 1252 END END