Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

CAN I DISABLE AUTO OFF USING CF?

8 views
Skip to first unread message

Dom

unread,
Dec 23, 2002, 5:36:37 AM12/23/02
to
Hi there,
Is it possible to disable the auto-off feature whilst a .NET app is
executing ?
Thanks,

Dom


Chris Nymann [MS]

unread,
Jan 8, 2003, 7:56:47 PM1/8/03
to
Hi,

To disable auto-off, do something like the attached code snippet form
pocketpc sdk via p/invoke.

Preventing Automatic Power Off
You can override the automatic suspend that occurs when no user input has
occurred for a period of time. To prevent automatic power off, call the
SystemParametersInfo function for each of the three timeout values,
SPI_GETBATTERYIDLETIMEOUT, SPI_GETEXTERNALIDLETIMEOUT, and
SPI_GETWAKEUPIDLETIMEOUT. Your application must call the
SystemIdleTimerReset function more frequently than any of the non-zero
timeout values.

DWORD batIdle, acIdle, wakeUpIdle, shortestIdle;
TCHAR szOutput[200];

// get the values
SystemParametersInfo(SPI_GETBATTERYIDLETIMEOUT,0,&batIdle,0);
SystemParametersInfo(SPI_GETEXTERNALIDLETIMEOUT,0,&acIdle,0);
SystemParametersInfo(SPI_GETWAKEUPIDLETIMEOUT,0,&wakeUpIdle,0);

// determine which is the lowest non-zero value
shortestIdle=batIdle;
shortestIdle=((acIdle>0)&&(acIdle<shortestIdle)) ? acIdle :
(((wakeUpIdle>0)&&(wakeUpIdle<shortestIdle)) ? wakeUpIdle : shortestIdle);

if (shortestIdle==0)
// if all values are zero, the device will never timeout
wsprintf(szOutput,_T("Battery Idle Timeout: %d\nAC Power Idle Timeout:
%d\nWakeup Idle Timeout: %d\nThe device will not timeout."),batIdle,
acIdle, wakeUpIdle);
else
{
// otherwise, you need to reset the idle timer more
// frequently than the lowest timeout value
wsprintf(szOutput,_T("Battery Idle Timeout: %d\nAC Power
Idle Timeout: %d\nWakeup Idle Timeout: %d\nYou need to
call SystemIdleTimerReset at least every %d
sec"),batIdle, acIdle, wakeUpIdle, shortestIdle-1);
}
MessageBox(hWnd,szOutput,_T("Results"),MB_OK);
Built on Friday, December 21, 2001


thanks.

0 new messages