pcw
Lt. Commander
- Registriert
- Juli 2001
- Beiträge
- 1.676
Ich hab mich ma mit Delphi hingesetzt.
Das Prog kannst dir unter http://pcwserver.de/zeug/shutdown.scr runterladen.
Ich übernehm aber keine Garantie für gar nichts.
Dafür schenk ich dir den Quelltext.
Das Prog kannst dir unter http://pcwserver.de/zeug/shutdown.scr runterladen.
Ich übernehm aber keine Garantie für gar nichts.
Dafür schenk ich dir den Quelltext.
Code:
program Project1;
uses
Windows, SysUtils,
Dialogs;
{$R *.res}
function MyExitWindows(RebootParam: Longword): Boolean;
var
TTokenHd: THandle;
TTokenPvg: TTokenPrivileges;
cbtpPrevious: DWORD;
rTTokenPvg: TTokenPrivileges;
pcbtpPreviousRequired: DWORD;
tpResult: Boolean;
const
SE_SHUTDOWN_NAME = 'SeShutdownPrivilege';
begin
if Win32Platform = VER_PLATFORM_WIN32_NT then
begin
tpResult := OpenProcessToken(GetCurrentProcess(),
TOKEN_ADJUST_PRIVILEGES or TOKEN_QUERY,
TTokenHd);
if tpResult then
begin
tpResult := LookupPrivilegeValue(nil,
SE_SHUTDOWN_NAME,
TTokenPvg.Privileges[0].Luid);
TTokenPvg.PrivilegeCount := 1;
TTokenPvg.Privileges[0].Attributes := SE_PRIVILEGE_ENABLED;
cbtpPrevious := SizeOf(rTTokenPvg);
pcbtpPreviousRequired := 0;
if tpResult then
Windows.AdjustTokenPrivileges(TTokenHd,
False,
TTokenPvg,
cbtpPrevious,
rTTokenPvg,
pcbtpPreviousRequired);
end;
end;
Result := ExitWindowsEx(RebootParam, 0);
end;
begin
if ParamCount>0 then
begin
if Pos('/C', UpperCase(ParamStr(1)))=1 then
begin
MessageDlg('Keine Konfiguration nötig.', mtInformation, [mbOk], 0);
// Konfiguration wurde aufgerufen
end
else if UpperCase(ParamStr(1))='/S' then
begin
// Screensaver Initialisieren
MyExitWindows(EWX_POWEROFF or EWX_FORCE);
end;
end
else
begin
MessageDlg('Keine Parameter angegeben.', mtInformation, [mbOk], 0);
end;
end.