Parameters:
EWX_SHUTDOWN : shut down windows(Power off)
EWX_REBOOT : reboot windows
EWX_POWEROFF : Standby mode
EWX_LOGOFF : Log Off

procedure TForm1.Button1Click(Sender: TObject);
begin
ExitWindowsEx(EWX_SHUTDOWN,0);
end;

or use rundll32.exe

uses ShellAPI;

function ExecuteFile(const FileName, Params,DefaultDir : string;
ShowCmd: Integer) : THandle;
var
zFileName, zParams, zDir : array[0..79] of Char;
begin
Result :=ShellExecute(Application.MainForm.Handle, nil,
StrPCopy(zFileName, FileName),StrPCopy(zParams,Params), StrPCopy(zDir, DefaultDir), ShowCmd);
end;

procedure TForm1.Button1Click(Sender: TObject);
begin
ExecuteFile('Rundll.exe','user,exitwindows','',SW_SHOW);
end;

8 Responses so far.

Post a Comment

Thank you for your comment.

Any request and idea are welcome.

CLICK TO REGISTER