Solved

Can machine suspend?

Posted on 1998-06-30
12
314 Views
Last Modified: 2013-12-03
How can it be determined if a machine is capable of suspending?
0
Comment
Question by:dmetzler
  • 5
  • 2
  • 2
  • +3
12 Comments
 
LVL 22

Expert Comment

by:nietod
ID: 1409022
What do you mean?  Do you mean the low-power screen saver?  that can be obtained from SystemParemetersInfo().
0
 

Author Comment

by:dmetzler
ID: 1409023
No - laptop machines can suspend (sleep).  I know how to place a machine in suspend mode (if it can).  I want to query a system to see if it is capable of suspending.  (Laptop machines have an additional Start Menu item below Shutdown for Suspend)

0
 
LVL 22

Expert Comment

by:nietod
ID: 1409024
I don't see a direct way.  But if there isn't a direct way, you might try using GetSystemPowerStatus() and looking to see if the computer has a battery.
0
 
LVL 2

Expert Comment

by:WDB
ID: 1409025
Check for the follwing Registry entry

HKEY_LOCAL_MACHINE\Enum\Root\*PNP0C05\0000\APMMenuSuspend

If it's there the system is cabable of suspending.
0
 

Author Comment

by:dmetzler
ID: 1409026
I have just checked the key on my desktop machine:

HKEY_LOCAL_MACHINE\Enum\Root\*PNP0C05\0000\APMMenuSuspend

This value shows up as 01, but this machine cannot suspend, nor does it have a Start Menu suspend option.
0
 
LVL 32

Expert Comment

by:jhance
ID: 1409027
I've not found it to be 100% reliable but the following code uses the SetSystemPowerState() function to try and do a suspend.  The problem with reliability is that not all laptops support the APM power functions.  Many provide their own interface to their own power management protocol and make it look like it's the same as Windows.  The problem is then that Windows only knows how to deal with APM.

void CRebootDialog::OnClickedSuspend()
{
    if(!SetSystemPowerState(FALSE, TRUE)){
        AfxMessageBox("Failed to initiate SUSPEND - Does your system support APM functions?");
        EndDialog(IDC_APMFAILED);
    }
    else{
        EndDialog(IDC_SUSPENDOK);
    }
}
0
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 

Author Comment

by:dmetzler
ID: 1409028
I need to know if this available BEFORE the machine attempts to suspend, as I want to make some options unavailable.
0
 
LVL 2

Expert Comment

by:kinkajou
ID: 1409029
Use an ACCESSTIMEOUT structure when calling the SystemParametersInfo() function with the uiAction parameter set to the SPI_GETACCESSTIMEOUT. You will be interested in some of the other functions/uiAction parameters available to SystemParametersInfo().
0
 

Author Comment

by:dmetzler
ID: 1409030
The ACCESSTIMEOUT structure and SystemParametersInfo seem to be used with the accessibility features, if installed, and not for a suspend.
0
 
LVL 2

Expert Comment

by:kinkajou
ID: 1409031
The WM_POWERBROADCAST message is sent to an application to notify it of power-management events.

dwPowerEvent = (DWORD) wParam;
dwData = (DWORD) lParam;
 
PBT_APMBATTERYLOW
 Battery power is low.
 
PBT_APMOEMEVENT
 OEM-defined event occurred.
 
PBT_APMPOWERSTATUSCHANGE
 Power status has changed.
 
PBT_APMQUERYSUSPEND
 Request for permission to suspend.
 
PBT_APMQUERYSUSPENDFAILED
 Suspension request denied.
 
PBT_APMRESUMECRITICAL
 Operation resuming after critical suspension.
 
PBT_APMRESUMESUSPEND
 Operation resuming after suspension.
 
PBT_APMSUSPEND
 
Can be used to determine if a suspend is goning to occur and you have time to do work or deny the suspension with BROADCAST_QUERY_DENY.


WM_POWERBROADCAST is sent by VPOWERD.VXD. There is a discussion in the 95DDK (KERNEL.DOC) about the VPOWERD handler services. The function you would want to use is:DWORD _VPOWERD_Get_Power_Management_Level (void); that returns the power management level of the system =
0 - both bios and cooperative power management on.
1 - bios power management on.
2 - power management off.

So, use LoadLibrary() to get the VPOWERD.VXD and GetProcAddress() to get _VPOWERD_Get_Power_Management_Level() and call the address of this function to get the return.

But I haven't seen an actual function in the SDK that will get the information you want.
0
 
LVL 2

Accepted Solution

by:
cessi0g earned 100 total points
ID: 1409032
You need to use VESA DPMS/VBE standars.
Try to use int 10h, with AX=4f10h and BX = 0.

Look at www.ctyme.com/intr/RB-0273.HTM
0
 

Author Comment

by:dmetzler
ID: 1409033
Great!  Thanks!

Don
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
WPF MainWindow update textbox from another class... 6 102
File Watcher and Deleter with Email notification 5 93
Problem to DocumentFormat 8 76
Problem to file 3 67
This tutorial is about how to put some of your C++ program's functionality into a standard DLL, and how to make working with the EXE and the DLL simple and seamless.   We'll be using Microsoft Visual Studio 2008 and we will cut out the noise; that i…
This article describes a technique for converting RTF (Rich Text Format) data to HTML and provides C++ source that does it all in just a few lines of code. Although RTF is coming to be considered a "legacy" format, it is still in common use... po…
This is Part 3 in a 3-part series on Experts Exchange to discuss error handling in VBA code written for Excel. Part 1 of this series discussed basic error handling code using VBA. http://www.experts-exchange.com/videos/1478/Excel-Error-Handlin…
In this video I am going to show you how to back up and restore Office 365 mailboxes using CodeTwo Backup for Office 365. Learn more about the tool used in this video here: http://www.codetwo.com/backup-for-office-365/ (http://www.codetwo.com/ba…

863 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

Need Help in Real-Time?

Connect with top rated Experts

25 Experts available now in Live!

Get 1:1 Help Now