Unable to P/Invoke System Timeout parameters

Z

Zeno Loco

I'm trying to get the timeout parameters from my device (Pocket PC
2003).
Looking in some example and newsgroup, I tested two different exaple
but, in both cases, the result is not valid (0 in the first test and
empty string in the second).
Here is the code :

1st test

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

.....

Const SPI_GETBATTERYIDLETIMEOUT = 252
Const SPI_GETEXTERNALIDLETIMEOUT = 254
Const SPI_GETWAKEUPIDLETIMEOUT = 256

......

Dim T1 As Integer, T2 As Integer, T3 As Integer
Dim R1 As Integer, R2 As Integer, R3 As Integer
R1 = SystemParametersInfo(SPI_GETBATTERYIDLETIMEOUT, 0, T1, 0)
R2 = SystemParametersInfo(SPI_GETEXTERNALIDLETIMEOUT, 0, T2, 0)
R3 = SystemParametersInfo(SPI_GETWAKEUPIDLETIMEOUT, 0, T3, 0)

2nd test

Declare Function SystemParametersInfoW Lib "Coredll.dll" Alias
"SystemParametersInfoW" _
(ByVal uiAction As System.UInt32, _
ByVal uiParam As System.UInt32, _
ByVal pvParam As StringBuilder, _
ByVal fWinIni As System.UInt32) As Boolean
.....

Dim SPI_GETBATTERYIDLETIMEOUT As System.UInt32 = 252
Dim SPI_GETEXTERNALIDLETIMEOUT As System.UInt32 = 254
Dim SPI_GETWAKEUPIDLETIMEOUT As System.UInt32 = 256

Dim T1 As New StringBuilder(200), T2 As New StringBuilder(200),
T3 As New StringBuilder(200)
Dim R1, R2, R3 As Boolean
R1 = SystemParametersInfoW(SPI_GETBATTERYIDLETIMEOUT, 200, T1,
0)
R2 = SystemParametersInfoW(SPI_GETEXTERNALIDLETIMEOUT, 200, T2,
0)
R3 = SystemParametersInfoW(SPI_GETWAKEUPIDLETIMEOUT, 200, T3,
0)

In some newsgroup I read that this code is working in 2002 O.S. but not
in 2003.
Any suggestion?

Thanks

Zeno
 
G

Guest

Your first try looks right (no idea what you were trying in the second).
What are the calls returning (in R1, R2, etc)? Did you call
Marshal.GetLastWin32Error after the call to see if an error is set?
 

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