Thread View: borland.public.cppbuilder.nativeapi
4 messages
4 total messages
Started by James5950
Fri, 20 Jun 2008 23:55
Which API can detect the PC going sleep?
Author: James5950
Date: Fri, 20 Jun 2008 23:55
Date: Fri, 20 Jun 2008 23:55
10 lines
1136 bytes
1136 bytes
Dear All, My application need close before PC into sleep mode. How can I do now? Thanks for any suggestions and comments, Best regards, James
Re: Which API can detect the PC going sleep?
Author: Remy Lebeau (TeamB)
Date: Sat, 21 Jun 2008 00:18
Date: Sat, 21 Jun 2008 00:18
12 lines
1216 bytes
1216 bytes
"James5950" <James@1come.com.tw> wrote in message news:485c4381@newsgroups.borland.com... > My application need close before PC into sleep mode. > How can I do now? Intercept the WM_POWERBROADCAST message and look for the PBT_APMSUSPEND notification. Gambit
Re: Which API can detect the PC going sleep?
Author: Colin B Maharaj
Date: Thu, 26 Jun 2008 12:26
Date: Thu, 26 Jun 2008 12:26
18 lines
1426 bytes
1426 bytes
Hi Remy, Is it possible to know if the sleep mode is available or turned on? Remy Lebeau (TeamB) wrote: > "James5950" <James@1come.com.tw> wrote in message > news:485c4381@newsgroups.borland.com... > >> My application need close before PC into sleep mode. >> How can I do now? > > Intercept the WM_POWERBROADCAST message and look for the PBT_APMSUSPEND > notification. > > > Gambit > >
Re: Which API can detect the PC going sleep?
Author: Darko Miletic
Date: Thu, 26 Jun 2008 13:58
Date: Thu, 26 Jun 2008 13:58
29 lines
1661 bytes
1661 bytes
Colin B Maharaj wrote:
> Hi Remy,
> Is it possible to know if the sleep mode is
> available or turned on?
>
Yes.
#define WIN32_NO_STATUS
#include <windows.h>
#undef WIN32_NO_STATUS
#include <ntstatus.h>
#include <powrprof.h>
#pragma comment(lib,"powrprof.lib")
bool SleepModePresent(void) {
SYSTEM_POWER_CAPABILITIES sc = {};
NTSTATUS ret = CallNtPowerInformation(
SystemPowerCapabilities,
NULL,
0ul,
&sc,
sizeof(sc)
);
return (ret == STATUS_SUCCESS)
&& ( sc.SleepButtonPresent);
}
Thread Navigation
This is a paginated view of messages in the thread with full content displayed inline.
Messages are displayed in chronological order, with the original post highlighted in green.
Use pagination controls to navigate through all messages in large threads.
Back to All Threads