🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

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

Re: Can't get the computer to programmatically wake from standby.... (original question in language cpp)

#1308
From: Bob Gonder
Date: Sat, 15 Sep 2007 00:03
39 lines
2460 bytes
Wiljo wrote:

>HANDLE hTimer = CreateWaitableTimer(NULL,TRUE,"VideoTimer");
>
>if( hTimer != NULL )
>{
>   CancelWaitableTimer( hTimer );

Redundant.
SetWaitableTimer cancels the timer first.

>   if( SetWaitableTimer(hTimer, &liDueTime, 0, NULL, NULL, true ))
To eliminate possible UTC problems, test with
    liDueTime.QuadPart=-200000000;	// 20 seconds
and see if it sleeps for 20 seconds.
>   {
Also, you should check this error as well....
fResume 
[in] If this parameter is TRUE, restores a system in suspended power conservation mode
when the timer state is set to signaled. Otherwise, the system is not restored. If the
system does not support a restore, the call succeeds, but GetLastError returns
ERROR_NOT_SUPPORTED. 

>     //* This executes a thread that uses
>     //* WaitForSingleObject( hTimer, 90000 );
>     mWaitingTest.mExecuteThread( new( HERE ) CWaitingThread( hTimer ));

I don't think hTimer is valid in another thread.
Your security attribute is set to "not-inheritable".

>     //* Here I initiate the Standby mode
>     //* But when I enable this the computer does not wake at
>     //* the desired time of one minute
>//  SetSuspendState( FALSE, FALSE, FALSE );

I think you should use a callback function in 
SetWaitableTimer. It would either finish the job of turning on
the power, or just post a message for your app to start recording.
It could also Delete the Timer so you could Create it the next time.
Technical Details
Message-ID: <u47me3ltdcd2btvkn32ib000kv676ljiun@4ax.com>
Path: arc1-ca.pugleaf.net!g2news2.google.com!news2.google.com!news.glorb.com!newsfeeds.ihug.co.nz!ihug.co.nz!newsgroups.borland.com!not-for-mail
References: <46eaf724$1@newsgroups.borland.com>

Show Full Headers
Complete Article Headers
X-Google-Thread: 10cc67,dbb9f35f467d4b41
X-Google-Attributes: gid10cc67,public,usenet
X-Google-Language: ENGLISH,ASCII-7-bit
From: Bob Gonder <notbg@notmindspring.invalid>
Newsgroups: borland.public.cppbuilder.nativeapi
Subject: Re: Can't get the computer to programmatically wake from standby.... (original question in language cpp)
Date: Fri, 14 Sep 2007 17:03:25 -0700
Organization: MindSpring Enterprises, Inc.
Reply-To: notbg@notmindspring.invalid
Message-ID: <u47me3ltdcd2btvkn32ib000kv676ljiun@4ax.com>
References: <46eaf724$1@newsgroups.borland.com>
X-Newsreader: Forte Agent 1.93/32.576 English (American)
MIME-Version: 1.0
Content-Type: text/plain; charset=us-ascii
Content-Transfer-Encoding: 7bit
NNTP-Posting-Host: 67.77.146.190
X-Trace: newsgroups.borland.com 1189814601 67.77.146.190 (14 Sep 2007 17:03:21 -0700)
Lines: 41
Path: arc1-ca.pugleaf.net!g2news2.google.com!news2.google.com!news.glorb.com!newsfeeds.ihug.co.nz!ihug.co.nz!newsgroups.borland.com!not-for-mail