unit Unit1;
interface
us
Windows, Messages, SysUtils, Variants, Class, Graphics, Controls, Forms,
Dialogs, StdCtrls;
type
TForm1 = class(TForm)
Button1: TButton;
Label1: TLabel;
感恩心
procedure Button1Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
function GetOperatingSystem(): string;
先斩后奏
procedure ShutDownComputer();
procedure Get_Shutdown_Privilege();
var
Form1: TForm1;
implementation
{$R *.dfm}
procedure TForm1.Button1Click(Sender: TObject);
begin
ShutDownComputer();
end;
procedure ShutDownComputer();
begin
转正群众意见
if GetOperatingSystem() = 'Windows NT/2000/XP' then
begin
Get_Shutdown_Privilege();
//调用此函数会出现系统关机提示窗口,并允许用户取消关机动作
徐州之战
InitiateSystemShutDown(nil, '关机提示:讨厌你所以关了你!', 3, True, Fal);
// InitiateSystemShutDown去掉的话就不显示提示窗口
ExitWindowsEx(EWX_SHUTDOWN+EWX_FORCE+EWX_POWEROFF+EWX_FORCEIFHUNG,0);
end
el
begin
ExitWindowsEx(EWX_SHUTDOWN+EWX_FORCE+EWX_POWEROFF+EWX_FORCEIFHUNG,0);
end;
end;
function GetOperatingSystem(): string; //获取操作系统信息
var
osVerInfo: TOSVersionInfo;
兔子好养吗
begin
Result:= '';
osVerInfo.dwOSVersionInfoSize:= SizeOf(TOSVersionInfo);
if GetVersionEx(osVerInfo) then
ca osVerInfo.dwPlatformId of
VER_PLATFORM_WIN32_NT:丝瓜怎么种
begin
Result:= 'Windows NT/2000/XP'
end;
VER_PLATFORM_WIN32_WINDOWS:
begin
Result := 'Windows 95/98/98SE/Me';
end;
end;
end;
procedure Get_Shutdown_Privilege(); //获得用户关机特权,仅对Windows NT/2000/XP
var
rl: Cardinal;
hToken: Cardinal;
tkp: TOKEN_PRIVILEGES;
begin
OpenProcessToken(GetCurrentProcess, TOKEN_ADJUST_PRIVILEGES or TOKEN_QUERY, hToken);
if LookupPrivilegeValue(nil, 'SeShutdownPrivilege', tkp.Privileges[0].Luid) then
begin
tkp.Privileges[0].Attributes:= SE_PRIVILEGE_ENABLED;
tkp.PrivilegeCount:= 1;
AdjustTokenPrivileges(hToken, Fal, tkp, 0, nil, rl);
end;
end;
车笔画顺序>网站推广论坛
end.