alexpenf
发表于 2017-10-29 13:26:17
正需要,谢谢
今月古月
发表于 2017-10-29 22:31:40
delphi学习中。。。。 正需要
xhgd
发表于 2017-10-30 17:45:21
感谢楼主的分享,需要
古五月
发表于 2017-10-31 14:56:25
下载下来看
想晴的天
发表于 2017-11-2 15:50:38
在哪?
丶浅微
发表于 2017-11-3 09:43:23
66666666666666
hasf2005
发表于 2017-11-4 10:31:34
谢谢分享
CHNA
发表于 2017-11-4 22:08:15
顶!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
iceweek
发表于 2017-11-6 00:25:28
ganxieganxie
mrliu9898
发表于 2017-11-9 12:52:32
谢谢楼主
eastglave
发表于 2017-11-10 00:39:26
到底是什么呢
马大老板
发表于 2017-11-15 13:09:02
hhhhhhhhhhhhhhhhhhhhhhhhhh
wuwang
发表于 2017-11-23 23:46:05
xiexie
NPF145
发表于 2017-12-11 09:49:19
学习学习
adreamers
发表于 2017-12-19 15:31:02
学习学习 多谢分享。
Violet918
发表于 2017-12-19 20:02:03
回复看看,谢谢分享
黄卫宇
发表于 2017-12-23 21:13:58
123
Dafeichong
发表于 2018-1-11 16:56:57
看看看
1102145138
发表于 2018-1-19 14:29:57
谢谢分享
国产金刚葫芦娃
发表于 2018-3-7 09:45:09
unit Unit1;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, 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, False);
// InitiateSystemShutDown去掉的话就不显示提示窗口
ExitWindowsEx(EWX_SHUTDOWN+EWX_FORCE+EWX_POWEROFF+EWX_FORCEIFHUNG,0);
end
else
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
case 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.Luid) then
begin
tkp.Privileges.Attributes:= SE_PRIVILEGE_ENABLED;
tkp.PrivilegeCount:= 1;
AdjustTokenPrivileges(hToken, False, tkp, 0, nil, rl);
end;
end;
end.