发信人: kingron(金龍)
整理人: teleme(2001-01-06 19:40:32), 站内信件
|
在NT中跟Win9x下是一样的。关键是要有关机的权限!在调用关机的函数之前请调用下面的函数就可以了:
procedure AdjustToken;
var
hdlProcessHandle : Cardinal;
hdlTokenHandle : Cardinal;
tmpLuid : Int64;
tkpPrivilegeCount : Int64;
tkp : TOKEN_PRIVILEGES;
tkpNewButIgnored : TOKEN_PRIVILEGES;
lBufferNeeded : Cardinal;
Privilege : array[0..0] of _LUID_AND_ATTRIBUTES;
begin
hdlProcessHandle := GetCurrentProcess;
OpenProcessToken(hdlProcessHandle,
(TOKEN_ADJUST_PRIVILEGES Or TOKEN_QUERY),
hdlTokenHandle);
// Get the LUID for shutdown privilege.
LookupPrivilegeValue('', 'SeShutdownPrivilege', tmpLuid);
Privilege[0].Luid := tmpLuid;
Privilege[0].Attributes := SE_PRIVILEGE_ENABLED;
tkp.PrivilegeCount := 1; // One privilege to set
tkp.Privileges[0] := Privilege[0];
// Enable the shutdown privilege in the access token of this
// process.
AdjustTokenPrivileges(hdlTokenHandle,
False,
tkp,
Sizeof(tkpNewButIgnored),
tkpNewButIgnored,
lBufferNeeded);
end;
【 在 zengwenguang 的大作中提到:】
:可以用Delphi实现Windows98的关闭或重启,但在NT中却没用,请问各位大虾如何实现?
:
:请回E-Mail:[email protected]
:......
---- ██████
█┏━━┓█
█┃之金┃█ Delphi版直达快车
█┃印龍┃█
█┗━━┛█
██████ |
|