求助一下,2000和XP下关机的API应该怎么写.怎么用.我的写了不行.
不要简单的写个函数哦..一定要写上获得权限那一段.谢了..
获取操作系统的权限:
procedure Tfrmmain.FormCreate(Sender: TObject);
var
hToken : THandle;
Tkp : TTokenPrivileges;
Zero:DWORD;
begin
OpenProcessToken(GetCurrentProcess(),TOKEN_ADJUST_PRIVILEGES or
TOKEN_QUERY,hToken);
LookupPrivilegeValue(nil,'SeShutdownPrivilege',tkp.Privileges[0].Luid);
Tkp.PrivilegeCount :=1;
Tkp.Privileges[0].Attributes := SE_PRIVILEGE_ENABLED;
AdjustTokenPrivileges(hToken,False,Tkp,SizeOf(TTokenPrivileges),nil,Zero);
end;
注销:Exitwindowsex(Ewx_logoff,0);
重启:Exitwindowsex(ewx_reboot,0);
关闭计算机:Exitwindowsex(ewx_shutdown or poweroff,0);