uses
  SysUtils,ShellAPI;        //ExitWindowsEx(EWX_SHUTDOWN,0);//关机
        ShellExecute(0,'open','shutdown.exe',' -f -s -t 0',nil,SW_HIDE); 上述两个都不行,help

解决方案 »

  1.   

    procedure ExitWindowsNT(uFlags: integer);
    var
      hToken: THANDLE;
      tkp, tkDumb: TTokenPrivileges;
      DumbInt: DWORD;
    begin
      FillChar(tkp, sizeof(tkp), 0);
      if not (OpenProcessToken(GetCurrentProcess, TOKEN_ADJUST_PRIVILEGES
        or TOKEN_QUERY, hToken)) then
        raise Exception.create('OpenProcessToken failed with code '
          + inttostr(GetLastError));  LookupPrivilegeValue(nil, pchar('SeShutdownPrivilege'),
        tkp.Privileges[0].Luid);  tkp.PrivilegeCount := 1;
      tkp.Privileges[0].Attributes := SE_PRIVILEGE_ENABLED;  AdjustTokenPrivileges(hToken, false, tkp, sizeof(tkDumb), tkDumb, DumbInt);  if GetLastError <> ERROR_SUCCESS then
        raise Exception.create('AdjustTokenPrivileges failed with code '
          + inttostr(GetLastError));  if not ExitWindowsEx(uFlags, 0) then
        raise Exception.create('ExitWindowsEx failed with code '
          + inttostr(GetLastError));
    end;
    调用
    ExitWindowsNT(EWX_FORCE or EWX_POWEROFF);
      

  2.   

    系统权限肯定的,我用administrator帐号登陆另外,使用一定要uses ShellAPI和windows啊我给分了