Turn off, turn on and set time for auto suspending

A

Arnaldo Fuziy

The function below was told to turn off, turn on and set the time for auto
suspending... But I couldn't get it to work... Could anyone help us?

Public Const SPI_SETBATTERYIDLETIMEOUT = 251
Public Const SPI_GETBATTERYIDLETIMEOUT = 252
Public Const SPI_SETEXTERNALIDLETIMEOUT = 253
Public Const SPI_GETEXTERNALIDLETIMEOUT = 253

Public Declare Function SystemParametersInfo Lib "Coredll" Alias
"SystemParametersInfoW" _
(ByVal uAction As Integer, _
ByVal uParam As Integer, _
ByRef lpvParam As Integer, _
ByVal fuWinIni As Integer) As Integer


Should be used like this:
Dim s As Integer
s = SystemParametersInfo(SPI_SETBATTERYIDLETIMEOUT, 0, 0, 0)

Thanks,

Arnaldo.
 
C

Chris Tacke, eMVP

Saying "it doesn't work" doesn't help us much. What behavior do you see,
and what are you trying to get it to do?

-Chris
 
A

Arnaldo Fuziy

Chris,

Sorry, I'll try to give more details over it... As a matter of fact, nothing
happens... No error, no change in the time setting for auto suspending and
it doesn't turn off auto suspend either...
What we need to do is turn off auto suspending before certain operations and
turn it back on... And for that, we were supposed to use
"SystemParametersInfo" API calling it with 0 and then with the
TimeOutInSeconds...

Tks,

Arnaldo.
 
G

Graham McKechnie

Arnaldo,

I posted the same problem a little while before you. I did have it working
when I was running on PC 2002, but since upgrading my PDA to W Mob 2003 a
couple of days ago it stopped working. However, I haven't had a reply to my
question yet.

The one thing I would suggest about your code is you need a variable for the
third parameter, not zero. This is where the value will be returned after
your call to SystemParametersInfo. If for instance you have your PDA set to
turn off after 1 minute while on battery, the variable say BatteryIdle would
come back with a value of 60 after the call.

It would then be necessary to call your own timer with an interval set to
some value less than 60secs. This timer when it fires would then call
SystemIdleTimerReset, that in theory should keep your PDA alive.

There is a complete example (in C) of how to do this in the Pocket PC 2003
SDK - search for "Preventing automatic power down", or you could look at my
post "Differences between 2002 and Win mobile 2003"

If, when I get it working again, I'll let you know.

You could compromise and force the issue. Since you can't set the battery
idle less than 1 minute. You could always just set a timer to fire every 50
secs calling SystemIdleTimerReset without ever calling SystemParametersInfo.


Graham

PS I just noticed you are calling it with SETBATTERYIDLETIMEOUT. I've never
tried that, but I presume by setting it with 0, you are actually telling it
to never time out. Try it the way in the example and see what you get. Are
you running PC2002 or 2003 on the PDA?
 
A

Arnaldo Fuziy

Sorry Graham took me so long to answer... I had already tried to hold the
value in a variable, unsuccesfully though...
We're already using the approach of calling the "TimerReset" but it makes a
mess in our code to keep calling the function from time to time... But it's
the only solution so far...

Our intention was really to disable automatic power down temporarily and set
it back on after our processing is done... For this purpose, it looks like
the solution would be to use the SystemParametersInfo function but it's
still not working...

We're running .Net CF SP1 in a PPC 2003 device.

Tks again,

Arnaldo.
 
G

Graham McKechnie

Arnaldo,
We're already using the approach of calling the "TimerReset" but it makes a
mess in our code to keep calling the function from time to time... But it's
the only solution so far...

Assuming we get this technique working again, I don't understand your above
comment.

Why should it make a mess of your code? All I had to do for PC 2002 was add
one extra timer. Did you consider that approach.?

Graham
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top