Delphi 关键 重启 注销

//在初始化的时候获取权限 
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_SHUTDOWN, 0);//close
ExitWindowsEx(EWX_REBOOT, 0);//reoot

ExitWindowsEx(EWX_LOGOFF,0)// 注销

posted @ 2015-09-21 14:58  刀小爱  阅读(283)  评论(0编辑  收藏  举报