一,为什么ExitWindowsEx在XP环境下无效?
二,哪里有比较好的API函数说明文档?别告诉我让我去MSDN上查,
请大家多多指教一下!!

解决方案 »

  1.   

    procedure Shutdown;
    var
      hToken:THANDLE;
      tkp:TOKEN_PRIVILEGES;
      ReturnLength,BufferLength: DWORD;
      ver:TOSVersionInfo;
    begin
      ver.dwOSVersionInfoSize:=sizeof(TOSVersionInfo);
      if not GetVersionEX(ver) then Exit;  if ver.dwPlatformId<VER_PLATFORM_WIN32_NT then
      begin
        ExitWindowsEx(EWX_POWEROFF or EWX_FORCE, 0);
        exit;
      end; // Get a token for this process.
     if not OpenProcessToken(GetCurrentProcess(), TOKEN_ADJUST_PRIVILEGES OR TOKEN_QUERY, hToken) then
     begin
       ShowMessage('OpenProcessToken');
       Exit;
     end;
    // Get the LUID for the shutdown privilege.
    //    SE_SHUTDOWN_NAME :="SeShutdownPrivilege";
    //    Dest:=@Buf[1];    LookupPrivilegeValue(nil,'SeShutdownPrivilege' , tkp.Privileges[0].Luid);    tkp.PrivilegeCount := 1;  // one privilege to set
        tkp.Privileges[0].Attributes := SE_PRIVILEGE_ENABLED;// Get the shutdown privilege for this process.
        BufferLength:=0;
        ReturnLength:=0;
        AdjustTokenPrivileges(hToken, LongBool(false), tkp, BufferLength,nil, ReturnLength);// Cannot test the return value of AdjustTokenPrivileges.   if GetLastError() <> ERROR_SUCCESS then
       begin
         ShowMessage('AdjustTokenPrivileges');
         Exit;
       end;
    // Shut down the system and force all applications to close.   if not ExitWindowsEx(EWX_POWEROFF or EWX_FORCE, 0) then
       begin
          ShowMessage('ExitWindowsEx');
          Exit;
       end;
    end;
      

  2.   

    api文档我记得www.delphifans.com上好像有一个
      

  3.   

    1,该函数在NT下是不能直接用的,好象要一定的权限处理才可以实现98以下功能!
    2,我这里有个很好的API文档,每个API都有DELPHI的例子,如果你要,请尽快联系我:)
      

  4.   

    TO  Kshape_zh(伟大的大伟):
      你好,请寄到我.mo,重谢你
      

  5.   

    你上QQ吗?
    我hotmail邮箱打开很慢
    我给你发消息了
      

  6.   

    TO  Kshape_zh(伟大的大伟):
      我上不了QQ,只有一个这个域信箱,没办法,
      

  7.   

    TO  Kshape_zh(伟大的大伟):
      我还是没有收到,可以再给我发一次吗?[email protected],谢谢你
      

  8.   

    TO  Kshape_zh(伟大的大伟):
       文档已收到,谢谢你.请接分
      

  9.   

    TO  Kshape_zh(伟大的大伟):
      根据规则,最多只能给79分,谢谢你