broadcasting registry changes

K

keith

Hey all,
I posted a question yesterday that gave me some leads
(http://groups-beta.google.com/group...c289ae31c59/77cedcb4df7c2a0c#77cedcb4df7c2a0c)
and after some dd I came up with the code below (.net cf, c#). I'm now
using SendMessageTimeout to broadcast WM_SETTINGCHANGE so the shell
will see the changes i've made to the registry (turning auto-suspend
off via 'BattSuspendTimeout' and 'BattPowerOff'). Even though
SendMessageTimeout returns a success value, it doesnt work(or atleast
do what i expected it to).
Thanks again, Keith

[DllImport("coredll.dll", SetLastError=true)]
public static extern Int32 SendMessageTimeout(IntPtr hWnd,
UInt32 Msg, UInt16 wParam,
string lParam, Int32 fuFlags,
Int32 uTimeout, ref UInt32 lpdwResult );
....
const UInt16 WM_SETTINGCHANGE = 0x001A;
const int SMTO_NORMAL = 0x00000000;
UInt32 result = 0;

string pEnv = "Power"; //registry leaf for BattPowerOff
int uu = SendMessageTimeout((IntPtr)hwnd_broadcast, WM_SETTINGCHANGE,
0, pEnv, SMTO_NORMAL, 3000, ref result);

pEnv = "Timeouts"; //registry leaf for BattSuspendTimeout
uu = SendMessageTimeout((IntPtr)hwnd_broadcast, WM_SETTINGCHANGE, 0,
pEnv, SMTO_NORMAL, 3000, ref result);
 
P

Peter Foot [MVP]

There are essentially two different approaches to how the system broadcasts
changes to settings - either using WM_SETTINGCHANGE or by signalling a named
event. If the latter you'll need to know the name of the event, which will
depend in many cases on the OEM. For example to get the system to react to
changes in the backlight settings you set either "BacklightChangeEvent" or
SDKBacklightChangeEvent". Unless you can find the event name from the SDK
headers, or google then that is a bit of a dead-end.

Peter
 

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