Registry Strangeness

  • Thread starter Thread starter Joseph Byrns
  • Start date Start date
J

Joseph Byrns

I am using :

RegSetValueEx(hKeySub, value, 0, KeyType.DWord, New Byte() {0}, 1)
on registry value:
System\CurrentControlSet\Control\Power\Timeouts\BattSuspendTimeout

to set the "Turn off device if not used for" field to 0 for the battery to
prevent the PDA going into standby. This function sucessfully changes the
regsitry value to 0 (seen when I look in the eVC++ remote registry editor).
When I go into the Settings on the PDA however (menu Start, Settings...), I
see the setting to be 5 minutes rather than zero???

If I repeat the process, but set the value to 0 using the registry editor
rather than my application everything works fine.

Any ideas?
 
Looks to me like you're setting the value type to REG_DWORD, but only
passing a single byte to set the value. A DWORD is four bytes, of course.

Paul T.
 
That would explain it, I originally thought it was 5 bytes (don't know why),
but with 5 bytes I got the same result.

Thanks.
 
Usually you just want to pass a 'pointer' to an DWORD value (casting its
type to LPBYTE). Then you don't have to know how big it is. In C, I'd use
sizeof() to pass the size, also, so you're totally separated from that
stuff.

Paul T.
 
Back
Top