Delphi重啟電腦、關閉計算機、注銷(退出當前用戶用其它用戶重新登錄系統)功能的實現代碼,在Delphi中算是比較基礎的例子了,程序運行後,窗體上有對應的控制按鈕,測試時候要注意哦,如果點擊關閉或重啟,電腦就會執行該項命令,要保存好你需要保存的內容。
01
unit
MainUnit;
02
interface
03
uses
04
Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
05
StdCtrls;
06
type
07
TMainForm =
class
(TForm)
08
Button1: TButton;
09
Button2: TButton;
10
Button3: TButton;
11
procedure
Button1Click(Sender: TObject);
12
Button2Click(Sender: TObject);
13
Button3Click(Sender: TObject);
14
private
15
GetPrivilege;
16
{ Private declarations }
17
public
18
{ Public declarations }
19
end
;
20
var
21
MainForm: TMainForm;
22
implementation
23
{$R *.DFM}
24
TMainForm
.
25
26
NewState: TTokenPrivileges;
27
lpLuid:
Int64
28
ReturnLength: DWord;
29
ToKenHandle:
Cardinal
30
begin
31
OpenProcessToken(GetCurrentProcess,
32
TOKEN_ADJUST_PRIVILEGES
33
OR
TOKEN_ALL_Access
34
STANDARD_RIGHTS_REQUIRED
35
TOKEN_QUERY,ToKenHandle);
36
LookupPrivilegeValue(
nil
,
'SeShutdownPrivilege'
,lpLuid);
37
NewState
PrivilegeCount:=
1
38
Privileges[
0
].Luid:=lpLuid;
39
].Attributes:=SE_PRIVILEGE_ENABLED;
40
ReturnLength:=
41
AdjustTokenPrivileges(ToKenHandle,
False
,NewState,
,ReturnLength);
42
43
44
45
46
ExitWindowsEx(EWX_REBOOT
EWX_POWEROFF,
);
47
48
49
50
51
ExitWindowsEx(EWX_SHUTDOWN
52
53
54
55
ExitWindowsEx(EWX_LOGOFF,
56
57
【Asphyre引擎】冒險島換裝Demo升級到最新版PXL,
本例效果圖: 代碼文件:unit Unit1;inte
//效果圖://繪制多條貝塞爾線時, 每條線的終點也是下條
本例效果圖: 代碼文件:unit Unit1;inter
function CreateThread( lpThre