急等解决,请高手指点,马上结贴

解决方案 »

  1.   

    //MyExitWindows(EWX_SHUTDOWN);  抄的function IsWin9x: Boolean;
    var
      OsInfo: TOSVERSIONINFO;
    begin
      OsInfo.dwOSVersionInfoSize := sizeof(TOSVERSIONINFO);
      GetVersionEx(OsInfo);
      Result := (OsInfo.dwPlatformId = VER_PLATFORM_WIN32_WINDOWS);
    end;function SetShutdownPrivilege(Enable: Boolean): Boolean;
    var
      PrevPrivileges: TTokenPrivileges;
      Privileges: TTokenPrivileges;
      Token: THandle;
      dwRetLen: DWord;
    begin
      Result := False;
      OpenProcessToken(GetCurrentProcess, TOKEN_ADJUST_PRIVILEGES or TOKEN_QUERY, Token);
      Privileges.PrivilegeCount := 1;
      if LookupPrivilegeValue(nil,'SeShutdownPrivilege', Privileges.Privileges[0].LUID) then
      begin
        if Enable then
          Privileges.Privileges[0].Attributes := SE_PRIVILEGE_ENABLED
        else
          Privileges.Privileges[0].Attributes := 0;
        dwRetLen := 0;
        Result := AdjustTokenPrivileges(Token, False, Privileges, SizeOf(PrevPrivileges), PrevPrivileges, dwRetLen);
      end;
      CloseHandle(Token);
    end;procedure MyExitWindows(const P:Word);
    begin
      Application.Terminate;
      if IsWin9x then
        ExitWindowsEx(EWX_FORCE or P, 0)
      else
      begin
        SetShutdownPrivilege(True);
        ExitWindowsEx(EWX_FORCE or P, 0);
        SetShutdownPrivilege(False);
      end;
    end;
      

  2.   

    要先取得NT 的管理员特权。ExitWindowsEx 函数应该有讲到那个取得特权的API。
      

  3.   

    TO:lobby(lobby)讲的好象也是 AdjustTokenPrivileges
      

  4.   

    该问题提过N次了Google上随便就能找到答案的http://lysoft.7u7.net