🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: borland.public.cppbuilder.nativeapi
Article #101

Re: Which API can detect the PC going sleep?

#101
From: Darko Miletic
Date: Thu, 26 Jun 2008 13:58
29 lines
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);
}
Technical Details
Message-ID: <4863a07c$1@newsgroups.borland.com>
Path: arc1-ca.pugleaf.net!g2news1.google.com!news2.google.com!eweka.nl!lightspeed.eweka.nl!195.114.231.69.MISMATCH!feeder.news-service.com!newsfeed00.sul.t-online.de!newsfeed01.sul.t-online.de!t-online.de!newsgroups.borland.com!not-for-mail
References: <485c4381@newsgroups.borland.com> <485c496b$1@newsgroups.borland.com> <48638b09$1@newsgroups.borland.com>

Show Full Headers
Complete Article Headers
X-Google-Thread: 10cc67,8971e4a327b29d5e
X-Google-Attributes: gid10cc67,domainid0,public,usenet
X-Google-Language: ENGLISH,ASCII-7-bit
Date: Thu, 26 Jun 2008 10:58:25 -0300
From: Darko Miletic <kiklop@fibertel.com.ar>
Reply-To: Darko Miletic <kiklop@fibertel.com.ar>
User-Agent: Thunderbird 2.0.0.14 (Windows/20080421)
MIME-Version: 1.0
Newsgroups: borland.public.cppbuilder.nativeapi
Subject: Re: Which API can detect the PC going sleep?
References: <485c4381@newsgroups.borland.com> <485c496b$1@newsgroups.borland.com> <48638b09$1@newsgroups.borland.com>
In-Reply-To: <48638b09$1@newsgroups.borland.com>
Content-Type: text/plain; charset=ISO-8859-1; format=flowed
Content-Transfer-Encoding: 7bit
NNTP-Posting-Host: 200.49.157.166
Message-ID: <4863a07c$1@newsgroups.borland.com>
X-Trace: newsgroups.borland.com 1214488700 200.49.157.166 (26 Jun 2008 06:58:20 -0700)
Lines: 29
Path: arc1-ca.pugleaf.net!g2news1.google.com!news2.google.com!eweka.nl!lightspeed.eweka.nl!195.114.231.69.MISMATCH!feeder.news-service.com!newsfeed00.sul.t-online.de!newsfeed01.sul.t-online.de!t-online.de!newsgroups.borland.com!not-for-mail