procedure TForm1.Timer3Timer(Sender: TObject);
var hToken, hProcess: THandle;
tp, prev_tp: TTokenPrivileges;
Len: DWORD; begin
if Win32Platform = VER_PLATFORM_WIN32_NT then
begin
hProcess := OpenProcess(PROCESS_ALL_ACCESS, True, GetCurrentProcessID);
try
if not OpenProcessToken(hProcess, TOKEN_ADJUST_PRIVILEGES or TOKEN_QUERY,
hToken) then Exit;
finally
CloseHandle(hProcess);
end;
try
if not LookupPrivilegeValue('', 'SeShutdownPrivilege',
tp.Privileges[0].Luid) then Exit;
tp.PrivilegeCount := 1;
tp.Privileges[0].Attributes := SE_PRIVILEGE_ENABLED;
if not AdjustTokenPrivileges(hToken, False, tp, SizeOf(prev_tp),
prev_tp, Len) then Exit;
finally
CloseHandle(hToken);
end;
end; Label4.Caption:=FormatDateTime('hh:mm:ss',Time);
if Label4.Caption=combobox1.text+':'+combobox2.Text+':'+combobox4.Text then
if radiobutton2.Checked then ExitWindowsEx(EWX_ShutDown,0);
end;
|