This code works well on NT and 2000. I believe it is also OK for 9x
function WinExit(iFlags : Integer) : Boolean;
// possible Flags:
// EWX_LOGOFF
// EWX_REBOOT
// EWX_SHUTDOWN
// EWX_POWEROFF
begin
Result := True;
if (SetPrivilege('SeShutdownPrivilege', true) = True) then begin
if (ExitWindowsEx(iFlags, 0) = True) then begin
Result := False;
end;
SetPrivilege('SeShutdownPrivilege', False);
end
else begin
Result := False;
end;
end;
Rob
Software engineer
Wild Software Ltd
[EMAIL PROTECTED]
----- Original Message -----
From: "Matthew Comb" <[EMAIL PROTECTED]>
To: "Multiple recipients of list delphi" <[EMAIL PROTECTED]>
Sent: Monday, June 18, 2001 10:44 AM
Subject: [DUG]: shutting down windows.
> Does anyone have any code for forcing the shutdown of a machine? I need it
> for both win98 and 2k.
>
> Cheers,
>
> Matt.
>
>
> --------------------------------------------------------------------------
-
> New Zealand Delphi Users group - Delphi List - [EMAIL PROTECTED]
> Website: http://www.delphi.org.nz
> To UnSub, send email to: [EMAIL PROTECTED]
> with body of "unsubscribe delphi"
>
---------------------------------------------------------------------------
New Zealand Delphi Users group - Delphi List - [EMAIL PROTECTED]
Website: http://www.delphi.org.nz
To UnSub, send email to: [EMAIL PROTECTED]
with body of "unsubscribe delphi"