Achso.... okay gut...!
Die Funktion ExWindows sieht bei mir folgendermaßen aus:
Delphi-Quellcode:
function ExWindows(
const AFlag: Word): Boolean;
var
vi : TOSVersionInfo;
hToken : THandle;
tp : TTokenPrivileges;
h : DWord;
begin
result:= false;
vi.dwOSVersionInfoSize:=SizeOf(vi);
if GetVersionEx(vi)
then
begin
if vi.dwPlatformId = VER_PLATFORM_WIN32_NT
then
begin
// Windows NT
if OpenProcessToken(GetCurrentProcess,TOKEN_ADJUST_PRIVILEGES,hToken)
then
begin
LookupPrivilegeValue(
nil,'
SeShutdownPrivilege',
tp.Privileges[0].Luid);
tp.PrivilegeCount := 1;
tp.Privileges[0].Attributes := SE_PRIVILEGE_ENABLED;
h := 0;
AdjustTokenPrivileges(hToken,False,
tp,0,PTokenPrivileges(
nil)^, h);
CloseHandle(hToken);
result := ExitWindowsEx(Aflag, 0);
end;
end
else
begin // Windows 95
Result := ExitWindowsEx(Aflag, 0);
end;
end;
end;
als Angemeldeter Benutzer funktioniert das auch

aber wie gesagt wenn keiner angemeldt ist nicht.