View: MFC redemarrer Windows

  1. 11 years ago by moifort
    1. // Fonction pour redemarrer Windows avec les MFC
    2.  
    3. void RestartWindows(void)
    4. {
    5.         // Declaration
    6.         HANDLE hToken;
    7.         TOKEN_PRIVILEGES tkp;
    8.  
    9.         // Get a token for this process.
    10.         OpenProcessToken(GetCurrentProcess(), TOKEN_ADJUST_PRIVILEGES | TOKEN_QUERY, &hToken);
    11.  
    12.  
    13.         // Get the LUID for the shutdown privilege. 
    14.         LookupPrivilegeValue(NULL, SE_SHUTDOWN_NAME,&tkp.Privileges[0].Luid);
    15.  
    16.         tkp.PrivilegeCount = 1// one privilege to set   
    17.         tkp.Privileges[0].Attributes = SE_PRIVILEGE_ENABLED;
    18.  
    19.         // Get the shutdown privilege for this process. 
    20.         AdjustTokenPrivileges(hToken, FALSE, &tkp, 0, (PTOKEN_PRIVILEGES)NULL, 0);
    21.  
    22.  
    23.         // Shut down the system and force all applications to close. 
    24.         ExitWindowsEx(EWX_REBOOT| EWX_FORCE, 0);
    25. }
    Paste this in your website: <script type="text/javascript" src="http://www.posteet.com/embed/377"></script>

0 comment about "MFC redemarrer Windows"