SetSystemPowerState
The SetSystemPowerState function suspends the system by shutting power down. Depending on the ForceFlag parameter, the function either suspends operation immediately or requests permission from all applications and device drivers before doing so. The calling process must have the SE_SHUTDOWN_NAME privilege. To enable the SE_SHUTDOWN_NAME privilege, use the AdjustTokenPrivileges function. For more information, see Privileges. BOOL SetSystemPowerState(
  BOOL fSuspend,  // system state
  BOOL fForce     // forced suspension option
);
Parameters
fSuspend 
Windows NT/2000: [in] Specifies the state of the system. If TRUE, the system is suspended. If FALSE, the system is hibernating. 
Windows 95/98: Ignored. fForce 
[in] Forced suspension. If TRUE, the function broadcasts a PBT_APMSUSPEND event to each application and driver, then immediately suspends operation. If FALSE, the function broadcasts a PBT_APMQUERYSUSPEND event to each application to request permission to suspend operation. 
Return Values
If power has been suspended and subsequently restored, the return value is nonzero.If the system was not suspended, the return value is zero. To get extended error information, call GetLastError. Res
If any application or driver denies permission to suspend operation, the function broadcasts a PBT_APMQUERYSUSPENDFAILED event to each application and driver. If power is suspended, this function returns only after system operation is resumes and related WM_POWERBROADCAST messages have been broadcast to all applications and drivers. Requirements 
  Windows NT/2000: Requires Windows 2000.
  Windows 95/98: Requires Windows 95 or later.
  Header: Declared in Winbase.h; include Windows.h.
  Library: Use Kernel32.lib.See Also
Power Management Overview, Power Management Functions, PBT_APMQUERYSUSPEND, PBT_APMQUERYSUSPENDFAILED, PBT_APMSUSPEND, WM_POWERBROADCAST 

解决方案 »

  1.   

    回复人:ginkgoboy(彝族舞曲) (2001-4-27 10:33:00)  得0分 你可以调出关机界面,由用户选择,其中就有睡眠状态一项。 
    回复人:ginkgoboy(彝族舞曲) (2001-4-27 10:40:00)  得0分 还有一种方法,你可以试一下:ExitWindowsEx( EWX_POWEROFF, 0 ); //注意:
    //1、主板需为ATX结构
    //2、如果是在NT下,可能要关系到优先级问题