c++ 에서는 아래의 코드대로(우선 권한을 얻고 시스템을 종료)하면 윈도우2000이상의 버전에서도 종료가 되는 듯 합니다.(윈도우2000에서 해본결과 "이제 컴퓨터를 끄셔도 안전합니다." 라는 메세지까지는 나왔으나 전원은 꺼지지 않았음..... 그러나 XP에서는 된다고함.... 근데 해보지는 않았음.)....
어쨌든 이소스를 어떻게 창조에서 이용해야할까요... 오죽하면 c++로 종료되는 실행파일만 따로 만들고 창조에서 그 파일을 실행할 생각까지 했답니당..ㅠ.ㅠ
고수님들 부탁해요~~
HANDLE hToken TOKEN_PRIVILEGES tkp;
// Get a token for this process.
if (!OpenProcessToken(GetCurrentProcess(), TOKEN_ADJUST_PRIVILEGES | TOKEN_QUERY, &hToken)) printf("OpenProcessToken");
// Get the LUID for the shutdown privilege.
LookupPrivilegeValue(NULL, SE_SHUTDOWN_NAME, &tkp.Privileges[0].Luid);
tkp.PrivilegeCount = 1; // one privilege to set tkp.Privileges[0].Attributes = SE_PRIVILEGE_ENABLED;
// Get the shutdown privilege for this process.
AdjustTokenPrivileges(hToken, FALSE, &tkp, 0, (PTOKEN_PRIVILEGES)NULL, 0);
// Cannot test the return value of AdjustTokenPrivileges.
if (GetLastError() != ERROR_SUCCESS) printf("AdjustTokenPrivileges");
// Shut down the system and force all applications to close.
if (!ExitWindowsEx(EWX_SHUTDOWN | EWX_FORCE, 0)) printf("ExitWindowsEx"); |