System wake up from Standby/Hibernate to be done Programmatically

G

Guest

Hi

I want the system to wake up from Sleep/Hibernate through an application
without user intervention.In this case even I dont know after how much time
the system needs to be waken up.It shall be based on certain event only.
No prior time is known that after 't' seconds the system shall wake up.

Pls let me know how it can be done in VC++.

Any WIN 32 API's available for the same.

Regards
 
G

Guest

Do you mean that you will be using a hardware event to wake the machine from
hibernation or sleep and then you need to have a user mode application do
something when the machine wakes up?
 
G

Guest

Hi John

Yeah the lid open event for my notebook shall trigger the wake up for the
system but I donot want any user intervention after he opens the lid i.e. he
shall be not pressing any keys to wake up the system.

Is there any method to do so or any Windows API to handle this scenario???

regards
bhatia
 
G

Guest

bhatia,

It will depend upon your notebook as to whether it can be configured to wake
up from suspend automatically when the lid is opened. My Toshiba for example,
is configured to automatically hibernate when I close the lid and
automatically resume when the lid is opened. There is a tab on the power
options that allows me to configure the setting controlling this.

A Win32 application can tell when the machine wakes up from sleep or
hibernation by monitoring the WM_POWERBROADCAST message in its message
handler.
 
G

Guest

Hi John

Thanx for your response.Whatever you have said here that is perfectly ok.I
can do that setting on my notebook.But what if the same thing has to be done
by my application i.e. wherein application wakes up the system on its own
when the lid is opened.This needs to be done programatically.Moreover what
you say for the notification message WM_POWERBROADCAST.That is bieng sent by
the OS only when the resume operation has been initiated.I want my
application to initiate the Resume operation and then OS will be firing the
broadcast message to other applications etc.
E.g. I can specify the time at which system shall resume after sleep using
SetThreadExecutionState() API in XP but that is not the correct solution and
moreover this API is used when the system has to be waken up for short
duration to carry out some task and then after completion of the task it
should go to sleep again.


I hope I'm able to explain what I want for my application.

Regards
Bhatia
 
G

Guest

There is no way for a Win32 application to resume the OS based on a hardware
event. The OS must be resumed before a Win32 application can do anything. To
do what I think you are suggesting would require writing a kernel mode driver
that intercepted the hardware event that is generated when the laptop lid is
opened. A kernel mode driver could then decide if the OS should be resumed
completely or go immediately back to sleep or into hibernation without
resuming completely.
 
G

Guest

Hi John

Thanx for your reply.But if we see our notebooks when we press Fn + F4 keys
the system wakes up.That is again Hardware event generated from keyboard and
it wakes up the system.Maybe as you have said in this case it might be
because of some driver that invokes the system wake up.Can you let me know
how it happens when Fn + F4 keys are pressed? Maybe it can be a clue for me.

Thanks and regards
bhatia
 
G

Guest

When the system is in hibernation the machine is completely turned off with
the exception of a tiny amount of current that is used to power the
electronic switching circuit for turning on the main power to the computer.
This switching circuit is connected to any switches such as the lid switch or
function key that be used to power on the computer.

When one of these switching circuits turns on the main power to the computer
the computer boots up just like any computer when it is first turned on. The
ROMBIOS does its POST initialization and then loads the first sector of the
hard disk into memory and executes the bootstrap code that is located in the
first disk sector. The bootstrap code loads NTLOADER from the root directory
of the hard drive and then NTLOADER reads the hibernation file from the hard
disk into memory by reading sectors on the hard disk using the ROMBIOS int
13h disk interface API.

The hibernation file is an image of the computer's memory that was written
to the hard drive when the computer went into hibernation. After the
hibernation file is read into memory, NTLOADER executes Windows kernel code
that does any re-initializes of the kernel mode device drivers and then
re-initializes the Windows GUI interface processes security logon and then
resumes execution of Win32 applications and services at the point the
computer was it was at when it went into hibernation.

As you can see from this brief overview there are no drivers involved in
actually waking a computer from hibernation and in fact the drivers are not
even re-initialized until just before the computer is about to resume normal
execution.

Waking a computer up that is in sleep mode is very similar with the
exception that power is turned off for everything but the computer memory so
that memory does not need to be written to the hard drive. But the switching
circuits are still used to turn on the main power to all of the other
circuits when it is necessary to wake the machine. Again there are no drivers
involved in actually waking the machine from sleep mode, it is done in the
electronic switching ciruits.
 
G

Guest

Hi Lisa,

On my Toshiba Satellite there is a "Toshiba Power Saver" Control Panel
applette that can be used to change what happens when the lid is closed and
opened. To get to this setting I go into the Control Panel -> Toshiba Power
Saver -> Power Save Modes -> Details -> System Power Mode. In this dialog
there is a drop down list for "When I close the lid" that can be set to "No
action".

After changing the setting to "No action" I can hibernate manually before
closing the lid and then when I open the lid nothing happens until I press
the power button.
 
G

Guest

Lisa,

You need to be sure to change the settings in both the top and bottom
windows on the "Power Saver Properties" page. The top window is for settings
that apply when the laptop is plugged in and the bottom windows is for
settings that apply when the laptop is running from the battery.

I've also found that the changes are sometimes lost if I don't click the
"Apply" button before the "OK" button that closes the "Power Saver
Properties" page.
 
G

Guest

Lisa,

On the left side of the dialog you need to select the profile that is used
when running on batteries. Select the "Normal" lightbulb that has the battery
beside it and then select the "No action" for "When I close the lid". You may
need to also change this for all of the other lightbulbs below the "Normal"
lightbulb depending on what profile is in use on your computer.
 
G

Guest

The dialog shows that you were running on AC when you opened the settings
dialog. Have you tried making the change with the AC unplugged and the
machine running from the battery?
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top