在使用user32.dll里面的Api函数  ExitWindowsEx 时 出现了一点小问题。
代码如下:
[ DllImport("user32") ]
public static extern long ExitWindowsEx(long uFlags, long dwReserved ) ; public static void ShoutDownWindows()  //关机
{
ExitWindowsEx(1,dwReserved);
}
public static void ReBootWindows()  //重启
{
ExitWindowsEx(2,dwReserved);
}
public static void LogOffWindows()  //注消
{
ExitWindowsEx(0,dwReserved);
}其中”注消“可以 但是关机,和重启,就没有什么反应。这是为什么?
操作系统:Windows2000 Server
以Administrator用启运行!那位大哥请指点一下!

解决方案 »

  1.   

    BOOL ExitWindowsEx(    UINT uFlags, // shutdown operation
        DWORD dwReserved  // reserved
       );
     ParametersuFlagsSpecifies the type of shutdown. This parameter must be some combination of the following values: Value Meaning
    EWX_FORCE Forces processes to terminate. When this flag is set, Windows does not send the messages WM_QUERYENDSESSION and WM_ENDSESSION to the applications currently running in the system. This can cause the applications to lose data. Therefore, you should only use this flag in an emergency.
    EWX_LOGOFF Shuts down all processes running in the security context of the process that called the ExitWindowsEx function. Then it logs the user off.
    EWX_POWEROFF Shuts down the system and turns off the power. The system must support the power-off feature.Windows NT: The calling process must have the SE_SHUTDOWN_NAME privilege. For more information, see the following Res section. Windows 95: Security privileges are not supported or required.
    EWX_REBOOT Shuts down the system and then restarts the system. Windows NT: The calling process must have the SE_SHUTDOWN_NAME privilege. For more information, see the following Res section. Windows 95: Security privileges are not supported or required.
    EWX_SHUTDOWN Shuts down the system to a point at which it is safe to turn off the power. All file buffers have been flushed to disk, and all running processes have stopped. Windows NT: The calling process must have the SE_SHUTDOWN_NAME privilege. For more information, see the following Res section. Windows 95: Security privileges are not supported or required.这个是delphi中的~~~