Celebrate National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

API(or other way) to put computer into standby mode.

Posted on 1999-07-04
7
Medium Priority
?
265 Views
Last Modified: 2008-02-01
I am writing a program and I would like to be able to put my computer into standby mode instantly through code.  Basically all I want to do is put the monitor in low power mode and spin down the hard drive.  Then when I come back all I want to do is have to move the mouse and then for the computer to come back on. Basically I want the same thing that happens when you walk away from your computer for half of an hour.  However, I want to be able to do it on the spot when I push a command button.  Thanks for any help!
0
Comment
Question by:gockickasha
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 4
  • 2
7 Comments
 
LVL 10

Expert Comment

by:viktornet
ID: 1521891
try this....

Turn monitor off:
  call SendMessage(0, WM_SYSCOMMAND, SC_MONITORPOWER, 0)

Turn monitor on :
  call SendMessage(0, WM_SYSCOMMAND, SC_MONITORPOWER, -1)

..-=ViKtOr=-..
0
 

Author Comment

by:gockickasha
ID: 1521892
Well, I tried this code and it did black out the monitor.... however, the light never went off like it was in power down mode and there was a blinking DOS text cursor.  This also doesn't allow me to spin down the hard drive.  If it is the best that can be done through VB let me know.  Thanks for your help!
0
 
LVL 7

Accepted Solution

by:
Inteqam earned 60 total points
ID: 1521893
Flags = (DWORD) lParam;
 

The PBT_APMQUERYSTANDBY message is sent to request permission to place the system in standby mode. An installable driver that grants permission should carry out preparations for changing to standby before returning. A driver receives this message through the WM_POWERBROADCAST message.

Parameters

Flags

Action flags. If bit 0 is 1, the installable driver can prompt the user for directions on how to prepare for the change to standby; otherwise, the driver must prepare without user interaction. All other bit values are reserved.

Return Value

Returns TRUE to grant the request to change to standby mode. To deny the request, return BROADCAST_QUERY_DENY.

Remarks

An installable driver should process this message by first determining whether permission to change to standby can be granted. It must not grant permission if doing so would cause a lost of data. The installable driver can prompt the user for directions on how to prepare for the change to standby only if bit 0 in the Flags parameter is set.
This message is not sent to applications.
0
Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

 
LVL 7

Expert Comment

by:Inteqam
ID: 1521894
dwData = (DWORD) lParam;
 

The PBT_APMRESUMESTANDBY message is sent as a notification that the system has resumed operation after being placed in standby mode. A driver receives this message through the WM_POWERBROADCAST message.

Parameters

dwData

Reserved; must be 0.

Return Value

No return value.

Remarks

This message is not sent to applications.
0
 
LVL 7

Expert Comment

by:Inteqam
ID: 1521895
dwData = (DWORD) lParam;
 

The PBT_APMSTANDBY message is sent immediately before the system is placed in standby mode. This message is typically sent when all installable drivers have returned TRUE to a previous PBT_APMQUERYSTANDBY message. A driver receives this message through the WM_POWERBROADCAST message. A window receives this message through the WM_POWERBROADCAST message.

Parameters

dwData

Reserved; must be 0.

Return Value

No return value.

Remarks

An installable driver should process this message by completing all tasks necessary to save data. Usually, no special action is required. This message may also be sent, without a prior PBT_APMQUERYSUSPEND message, if an application or device driver uses the SetSystemPowerState function to force suspension.
This message is not sent to applications.
0
 

Author Comment

by:gockickasha
ID: 1521896
Could you possibly expand on this?  For example, what would I put in a command_click event to put the system into standby mode?  I am kind of a beginner with VB and I not sure how to send those messages.  Thanks a lot!
0
 
LVL 7

Expert Comment

by:Inteqam
ID: 1521897
do you know about subclassing

i think  you must learn sum before start with this.

0

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Since upgrading to Office 2013 or higher installing the Smart Indenter addin will fail. This article will explain how to install it so it will work regardless of the Office version installed.
This article describes how to use a set of graphical playing cards to create a Draw Poker game in Excel or VB6.
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…
Suggested Courses

730 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