Dom
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.