LoveXin
发表于 2015-4-2 12:48:31
159
~流星泪~
发表于 2015-4-2 19:29:29
{:1_1:}好东西
309194626
发表于 2015-4-3 16:41:13
1111111
phs3977
发表于 2015-4-3 23:32:40
有点意思,下下来再说
zdslua
发表于 2015-4-4 00:08:15
慢慢学基础
后知后觉L
发表于 2015-5-6 21:50:06
tansunny
发表于 2015-5-6 21:55:53
dingqilai!
hawnsyc
发表于 2015-5-7 12:40:11
学习一下
暮雪千山
发表于 2015-5-7 15:12:13
我想学习下谢谢老师
利威尔
发表于 2015-5-7 21:01:32
补补哦不错呦!!
shisan_
发表于 2015-5-8 17:11:46
下来看看
bowk
发表于 2015-5-9 07:48:54
感覺還不錯
可以好好熟悉delphi
罗格所罗门
发表于 2015-5-10 08:05:50
学习下,看看我能做多少
qwqwqlk
发表于 2015-5-10 17:43:19
看看文件有多大
Cage
发表于 2015-5-12 00:45:09
楼主好!~
2462336103
发表于 2015-5-13 16:17:22
过来 学习的!
JonesMahe
发表于 2015-5-15 16:19:49
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.
叶の落
发表于 2015-5-17 15:31:10
看看学学
boomyear
发表于 2015-5-22 16:18:19
这本书倒是没见过。希物了。。。。。。
citian3094
发表于 2015-5-22 19:05:40
谢谢分享!!