ExitWindows

 

Does anyone know how to access the function ExitWindows in

User.exe. I would like to use this function to restart windows

without restarting the computer.

[Mike O'Hanlon, TMike@IAfrica.com]

Here are examples of how to restart Windows and also how to reboot the system:

 


    procedure TMainForm.RestartWindowsBtnClick(Sender: TObject);

    begin

      if not ExitWindows(EW_RestartWindows, 0) then

        ShowMessage('An application refused to terminate');

    end;

 

 


    procedure TMainForm.RebootSystemBtnClick(Sender: TObject);

    begin

      if not ExitWindows(EW_RebootSystem, 0) then

        ShowMessage('An application refused to terminate');

    end;

 


The ExitWindows function has always been wrongly documented - Microsoft got it wrong in their documents and every one else followed along with the incorrect info. I believe the correct definition is:

 


    function ExitWindows (dwReturnCode: Longint;

                          Reserved: Word): Bool;