Type a page name and press Enter. You'll jump to the page if it exists, or you can create it if it doesn't.
To create a page in a module other than powrprof, prefix the name with the module name and a period.
setsuspendstate (powrprof)
.
Suspendss the current machine.
If hibernate = true, the system hibernates.
If hibernate = false, the system enters a standby state.
Declare Function SetSuspendState Lib "powrprof.dll" (ByVal Hibernate As Boolean, ByVal ForceCritical As Boolean, ByVal DisableWakeEvent As Boolean) As Boolean
User-Defined Types:
None.
Notes:
None.
Tips & Tricks:
Please add some!
Sample Code:
using System.Runtime.InteropServices;
namespace Sleeper
{
class Program
{
/// <summary>
/// Suspends the system by shutting power down. Depending on the Hibernate parameter, the system either enters a suspend (sleep) state or hibernation (S4).
/// </summary>
/// <param name="hibernate">If this parameter is TRUE, the system hibernates. If the parameter is FALSE, the system is suspended.</param>
/// <param name="forceCritical">Windows Server 2003, Windows XP, and Windows 2000: If this parameter is TRUE,
/// the system suspends operation immediately; if it is FALSE, the system broadcasts a PBT_APMQUERYSUSPEND event to each
/// application to request permission to suspend operation.</param>
/// <param name="disableWakeEvent">If this parameter is TRUE, the system disables all wake events. If the parameter is FALSE, any system wake events remain enabled.</param>
/// <returns>If the function succeeds, the return value is true.</returns>
/// <remarks>See http://msdn.microsoft.com/en-us/library/aa373201(VS.85).aspx</remarks>
[DllImport("Powrprof.dll", SetLastError = true)]
static extern uint SetSuspendState(bool hibernate, bool forceCritical, bool disableWakeEvent);
'SetSuspendState will put the PC in to a standby mode
Private Declare Function SetSuspendState Lib "powrprof.dll" (ByVal Hibernate As Boolean, ByVal ForceCritical As Boolean, _
ByVal DisableWakeEvent As Boolean) As Boolean
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
'SetSuspendState Example
'*************************************************************************************************
'SetSuspendState(False, False, False)
'*************************************************************************************************
End
End Sub
Alternative Managed API:
.Net 2.0 provides this managed method with identical arguments:
Public Shared Function SetSuspendState(ByVal state As System.Windows.Forms.PowerState, ByVal force As Boolean, ByVal disableWakeEvent As Boolean) As Boolean
Member of System.Windows.Forms.Application
Summary:
Suspends or hibernates the system, or requests that the system be suspended or hibernated.
Parameters:
state: A System.Windows.Forms.PowerState indicating the power activity mode to which to transition.
force: true to force the suspended mode immediately; false to cause Windows to send a suspend request to every application.
disableWakeEvent: true to disable restoring the system's power status to active on a wake event, false to enable restoring the system's power status to active on a wake event.
Return Values:
true if the system is being suspended, otherwise, false.
ByVal is a VB keyword that specifies a variable to be passed as a parameter BY VALUE. In other words, if the function or sub changes the value of the internal variable, it does not change the value of the external variable that was passed to it.
4/25/2007 3:19:55 AM - josep1er@cmich.edu-141.209.229.179
ByVal is a VB keyword that specifies a variable to be passed as a parameter BY VALUE. In other words, if the function or sub changes the value of the internal variable, it does not change the value of the external variable that was passed to it.
4/25/2007 3:19:55 AM - josep1er@cmich.edu-141.209.229.179
ByVal is a VB keyword that specifies a variable to be passed as a parameter BY VALUE. In other words, if the function or sub changes the value of the internal variable, it does not change the value of the external variable that was passed to it.
4/25/2007 3:19:55 AM - josep1er@cmich.edu-141.209.229.179
Please edit this page!
Do you have...
helpful tips or sample code to share for using this API in managed code?
corrections to the existing content?
variations of the signature you want to share?
additional languages you want to include?
Select "Edit This Page" on the right hand toolbar and edit it! Or add new pages containing supporting types needed for this API (structures, delegates, and more).