Re: SystemParametersInfo & Idle Timeout on Pocket PC 2003 by Panhuber
Panhuber
Thu Jul 31 09:27:03 CDT 2003
Hi!
I found the solution! I LOVE google! I found it with google (in
msdn.microsoft.com), but the page no longer exists. Thanks to google-Cache!
On PocketPC 2003 you have to read and change the timeout-settings via
registry.
Here is how to read:
DWORD dwBatIdleTimeout, dwExtIdleTimeout;
CRegKey reg;
reg.Create(HKEY_LOCAL_MACHINE, RK_SYSTEM_CCS_CONTROL_POWER);
reg.QueryValue(dwBatIdleTimeout, RV_BATTPOWEROFF);
reg.QueryValue(dwExtIdleTimeout, RV_EXTPOWEROFF);
reg.Close();
Here is how to write:
HANLDE hTimeoutChangeEvent = CreateEvent(NULL, FALSE, FALSE,
L"PowerManager/ReloadActivityTimeouts");
DWORD dwBatTimeout = <value in sec>;
CRegKey reg;
reg.Create(HKEY_LOCAL_MACHINE, RK_SYSTEM_CCS_CONTROL_POWER);
reg.SetValue(dwBatTimeout, RV_BATTPOWEROFF);
reg.Close();
SetEvent(hTimeoutChangeEvent); //inform system about new settings!
astrid
"Panhuber Astrid - PA" <pa@TimbaTecNOSPAM.com> schrieb im Newsbeitrag
news:%23ZLf82zVDHA.2352@TK2MSFTNGP12.phx.gbl...
> Hi!
>
> I have searched and found an example for SystemParametersInfo. They call
> SPI_SETBATTERYIDLETIMEOUT as follows:
>
> /*
> SPI_SETBATTERYIDLETIMEOUT
> Sets the amount of time that Windows CE will stay on with battery power
> before it suspends due to user inaction. The Windows CE operating system
> will remain on, with battery power, as long as the keyboard or touch
screen
> is active. The uiParam parameter specifies the time to set in seconds.
> This flag is ignored if uiParam is set to zero.
> */
> DWORD spiSETBATTERYIDLETIMEOUT (DWORD *timeout){
> BOOL fRetStatus = FALSE;
> UINT uiParam = 0;
>
> fRetStatus = SystemParametersInfo( SPI_SETBATTERYIDLETIMEOUT, uiParam,
> timeout, 0 );
> return fRetStatus;
> }
>
> Therefore I have changed my code as follows:
>
> DWORD timeout = 2*60;
> UINT uiParam = 0;
> SystemParametersInfo( SPI_SETBATTERYIDLETIMEOUT, uiParam, &timeout, 0 );
>
> Now I get error code 122 - ERROR_INSUFFICIENT_BUFFER.
>
> The call to SPI_GETBATTERYIDLETIMEOUT is the same as in my application and
> it's also the same result: 0.
>
> any ideas?
>
> astrid
>
>
> "Panhuber Astrid - PA" <pa@TimbaTecNOSPAM.com> schrieb im Newsbeitrag
> news:u8CdLRzVDHA.2352@TK2MSFTNGP12.phx.gbl...
> > hi!
> >
> > I'm using the following code in order to read out the idle timeout:
> >
> > UINT dwBatIdleTimeout;
> > SystemParametersInfo(SPI_GETBATTERYIDLETIMEOUT, 0, &dwBatIdleTimeout,
> 0);
> >
> > On Pocket PC 2002 this works fine.
> > On Pocket PC 2003 the function returns TRUE but dwBatIdleTimeout is
always
> > 0.
> >
> > I use the following code to set the idle timeout:
> >
> > SystemParametersInfo(SPI_SETBATTERYIDLETIMEOUT, /*dwBatTimeout*/3*60,
> > NULL, 0);
> >
> > On Pocket PC 2002 this works fine.
> > On Pocket PC 2003 the function returns FALSE, GetLastError returns 87 -
> > wrong parameter.
> >
> > According to the help, the syntax of SystemParametersInfo is the same on
> > Pocket PC 2002 and Pocket PC 2003. I'm using HP iPAQ 5450 (Pocket PC
2002)
> > and HP iPAQ 5550 (Pocket PC 2003). Any ides how to get and set the idle
> > timeout on Pocket PC 2003?
> >
> > Thanks in advance,
> > astrid
> >
> >
>
>