the routine for as well local as remote shutdown.
My routine looks like:
{===================================================================}
procedure PerformReboot;
{===================================================================}
VAR ErrorCode : DWORD;
UserMsg : string;
// hToken : THandle;
begin
UserMsg := 'Reboot required because of microsoft patch ' +
PPatchSettings
(_PatchSettings.Items[grdPatches.ActiveRow-1])^.PatchID + ' installation!"';
if CompSettings.ComputerName = '' then begin
if EnablePrivilege ('SeShutdownPrivilege') = 0 then begin
MessageDlg('Unable to set the "SeShutdownPrivilege" privilege',
mtError, [mbOK], 0);
end;
end
else begin
if EnablePrivilege ('SeRemoteShutdownPrivilege') = 0 then begin
MessageDlg('Unable to set the "SeRemoteShutdownPrivilege"
privilege', mtError, [mbOK], 0);
end;
end;
if InitiateSystemShutdown (PChar (CompSettings.ComputerName),
PChar (UserMsg),
_RebootDelay,
false,
true) then begin
MessageDlg('Reboot succesfully requested over and interval of ' +
IntToStr (_RebootDelay) + ' seconds', mtInformation, [mbOK], 0);
end
else begin
ErrorCode := GetLastError;
case ErrorCode of
ERROR_ACCESS_DENIED : begin
if CompSettings.ComputerName = '' then begin
MessageDlg('You do not have enough privilege to reboot this
computer', mtError, [mbCancel], 0);
end
else begin
MessageDlg('You do not have enough privilege to reboot this
computer' + cr +
'Probable the "Administrator" group does not have the
"Force shutdown from a remote system" user right', mtError, [mbCancel], 0);
end;
end;
else begin
MessageDlg(format ('Error %d (%s) requesting reboot', [ErrorCode,
SysErrorMessage (ErrorCode)]), mtError, [mbOK], 0);
end;
end;
end;
end;
kind regards,
Ronny Aerts
Belgium
----- Original Message -----
From: "eCcOns" <[EMAIL PROTECTED]>
To: <[email protected]>
Sent: Thursday, April 06, 2006 6:33 AM
Subject: [delphi-en] shutdown windows remotely
>i have difficulty abaut shutdown windows remotely..
> can you help me or suggest site abaut that..
>
> Thx
>
>
> -----------------------------------------------------
> Home page: http://groups.yahoo.com/group/delphi-en/
> To unsubscribe: [EMAIL PROTECTED]
> Yahoo! Groups Links
>
>
>
>
>
>
>
>
>
-----------------------------------------------------
Home page: http://groups.yahoo.com/group/delphi-en/
To unsubscribe: [EMAIL PROTECTED]
YAHOO! GROUPS LINKS
- Visit your group "delphi-en" on the web.
- To unsubscribe from this group, send an email to:
[EMAIL PROTECTED]
- Your use of Yahoo! Groups is subject to the Yahoo! Terms of Service.

