Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
?
Solved

Wake from Hibernation or Standby

Posted on 2005-04-25
2
Medium Priority
?
1,309 Views
Last Modified: 2010-04-04
How can I wake the computer from Hibernation or Standby?

Is there any common method that will wake the machine from both states, or will I need to use two different methods? Is the hibernation one even possible since the machine is powered off?

I know that at least the standby one is possible since there are programs such as 'Auto Power-on and Shut-down' that can do this.
0
Comment
Question by:paulb1989
2 Comments
 
LVL 7

Expert Comment

by:DavidBirch2dotCom
ID: 13861634
hum, normaly jogging the mouse would wake it up, prehaphs moving the mouse by code would wake it up ?  I dont use this feature so I am afraid i cant test this for you, but would

procedure SetMousePos(x, y: longint);
var pt: TPoint;
begin
  pt := ClientToScreen(point(x, y));
  SetCursorPos(pt.x, pt.y);
end;

 work? or you could try similulating a key press ?

David
0
 
LVL 26

Accepted Solution

by:
Russell Libby earned 2000 total points
ID: 13861794
You can wake the system up, but it must be done from a waitable timer, or from a device event. (the easier of the 2 being a waitable timer). For further info, you should refer to:

http://msdn.microsoft.com/library/default.asp?url=/library/en-us/power/base/power_management.asp

I am also providing a SIMPLE example that is able to resume the computer after 15 seconds. (I tested this, and it worked for both standby as well as hibernation)

Regards,
Russell


unit Unit1;

interface

uses
  Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs;

type
  TWakeupThread     = class(TThread)
  private
     FTime:         Int64;
  protected
     procedure      Execute; override;
  public
     constructor    Create(Time: Int64);
  end;

type
  TForm1         =  class(TForm)
  private
     // Private declarations
  protected
     // Protected declarations
     procedure WMPowerBroadcast(var Msg: TMessage); message WM_POWERBROADCAST;
  public
     // Public declarations
  end;

const
  PBT_APMQUERYSUSPEND        = 0;
  PBT_APMQUERYSTANDBY        = 1;
  PBT_APMQUERYSUSPENDFAILED  = 2;
  PBT_APMQUERYSTANDBYFAILED  = 3;
  PBT_APMSUSPEND             = 4;
  PBT_APMSTANDBY             = 5;
  PBT_APMRESUMECRITICAL      = 6;
  PBT_APMRESUMESUSPEND       = 7;
  PBT_APMRESUMESTANDBY       = 8;

var
  Form1: TForm1;

implementation
{$R *.DFM}

procedure TWakeupThread.Execute;
var  hTimer:     THandle;
begin

  // Create a waitable timer.
  hTimer:=CreateWaitableTimer(nil, True, 'WaitableTimer');
  if (hTimer <> 0) then
  begin
     if (SetWaitableTimer(hTimer, FTime, 0, nil, nil, True)) then
     begin
        WaitForSingleObject(hTimer, INFINITE);
     end;
     CloseHandle(hTimer);
  end;

end;

constructor TWakeupThread.Create(Time: Int64);
begin

  inherited Create(False);
  FreeOnTerminate:=True;
  FTime:=Time;

end;

procedure TForm1.WMPowerBroadcast(var Msg: TMessage);
begin

  // Check for suspend operation
  case Msg.wParam of
     // Query for allowing suspend
     PBT_APMQUERYSUSPEND      :  Msg.Result:=1;
     // We ARE being suspended (wake up in 15 seconds)
     PBT_APMSUSPEND       :  TWakeupThread.Create(-150000000);
  end;

end;

end.

0

Featured Post

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction The parallel port is a very commonly known port, it was widely used to connect a printer to the PC, if you look at the back of your computer, for those who don't have newer computers, there will be a port with 25 pins and a small print…
Creating an auto free TStringList The TStringList is a basic and frequently used object in Delphi. On many occasions, you may want to create a temporary list, process some items in the list and be done with the list. In such cases, you have to…
This lesson discusses how to use a Mainform + Subforms in Microsoft Access to find and enter data for payments on orders. The sample data comes from a custom shop that builds and sells movable storage structures that are delivered to your property. …
Despite its rising prevalence in the business world, "the cloud" is still misunderstood. Some companies still believe common misconceptions about lack of security in cloud solutions and many misuses of cloud storage options still occur every day. …
Suggested Courses

571 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question