시스템 종료함수
procedure ShutDown(dwTimeOut : DWord = 0; bForceClose : Boolean = true; bReboot : Boolean = false) ;
var
PreviosPrivileges: ^TTokenPrivileges;
TokenPrivileges: TTokenPrivileges;
hToken: THandle;
tmpReturnLength: DWord;
begin
if Win32Platform = VER_PLATFORM_WIN32_NT then begin
if OpenProcessToken(GetCurrentProcess(), TOKEN_ADJUST_PRIVILEGES or TOKEN_QUERY, hToken) then begin
LookupPrivilegeValue(Nil, 'SeShutdownPrivilege', TokenPrivileges.Privileges[0].Luid);
TokenPrivileges.PrivilegeCount := 1;
TokenPrivileges.Privileges[0].Attributes := SE_PRIVILEGE_ENABLED;
tmpReturnLength := 0;
PreviosPrivileges := nil;
AdjustTokenPrivileges(hToken, False, TokenPrivileges, 0, PreviosPrivileges^, tmpReturnLength);
if InitiateSystemShutdown(Nil, Nil, dwTimeOut, bForceClose, bReboot) then begin
TokenPrivileges.Privileges[0].Attributes := 0;
AdjustTokenPrivileges(hToken, False, TokenPrivileges, 0, PreviosPrivileges^, tmpReturnLength);
end ;
end ;
end
else
ExitWindowsEx(EWX_FORCE or EWX_SHUTDOWN or EWX_POWEROFF, 0);
end ;
'델파이' 카테고리의 다른 글
delphi ForceDeleteDirContent(); (0) | 2019.09.30 |
---|---|
시스템 제어관련 정보 (0) | 2019.09.30 |
OS버전 체크 (0) | 2019.09.27 |
메모리 사용정보 (0) | 2019.09.27 |
CPU 속도 체크 (0) | 2019.09.26 |