geoka
asked on
shutdown/reboot win nt4
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
ok. thx for amswers but can't try in next week so you must wait a few days for your points.
yours,
geoka
yours,
geoka
ASKER
uuhhh (Edited by Computer101), i wanted to deliver the points to jaymol. may you give the points daniel_c, i'm afraid, but only his comment worked under NT.
You need this really...
unit ExitWin;
interface
uses
Windows;
function PlatformNT : boolean;
function ExitWindowsF(uFlags : word) : boolean;
implementation
const
ANYSIZE_ARRAY = 1;
SE_SHUTDOWN_NAME = 'SeShutdownPrivilege';
var
IsNT : boolean;
function PlatformNT : boolean;
begin
PlatformNT:=IsNT;
end;
function ExitWindowsNT(uFlags : word) : boolean;
var
hToken : THandle;
ptkp, ptkpold : PTokenPrivileges;
r : dword;
begin
if OpenProcessToken(GetCurren
{$IFDEF DELPHI2}
TOKEN_ADJUST_PRIVILEGES or TOKEN_QUERY, @hToken) then
{$ELSE}
TOKEN_ADJUST_PRIVILEGES or TOKEN_QUERY, hToken) then
{$ENDIF}
begin
GetMem(ptkp,sizeof(TTOKENP
(1-ANYSIZE_ARRAY) * sizeof(TLUIDANDATTRIBUTES)
LookupPrivilegeValue(nil, SE_SHUTDOWN_NAME,
ptkp^.Privileges[0].Luid);
ptkp^.PrivilegeCount:=1;
r:=0;
ptkpold:=nil;
if AdjustTokenPrivileges(hTok
end;
ExitWindowsNT:=GetLastErro
end;
function ExitWindowsF(uFlags : word) : boolean;
begin
if IsNT then ExitWindowsF:=ExitWindowsN
else ExitWindowsF:=ExitWindowsE
end;
procedure CheckOS;
var
VerInfo : TOSVersionInfo;
begin
IsNT:=false;
VerInfo.dwOSVersionInfoSiz
if (GetVersionEx(VerInfo)) then
IsNT:=VerInfo.dwPlatformId
end;
begin
CheckOS;
end.
Save that as a unit, put it in your uses clause, and away you go! (Works on any windows platform.)
John.