Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

registry updates through .net apps 1

Status
Not open for further replies.

benlogan1981

Programmer
Dec 9, 2001
14
GB
Hi

I am trying to enable my application to control certain elements of the control panel, like for example the mouse speed. I can find this in the registry and change the values ok, but a system restart is required in order for them to take effect. When you modify mouse speed in the control panel you can see it changes in real time without the need for a restart. I can not have the users required to reboot. Basically I would like to know how to control variables such as this in the correct manner, in order to see their changes taking effect immediately.

Regards

Ben
 
Well, you could import BroadcastSystemMessage and then broadcast a WM_SETTINGCHANGE to all recipients.
In the wParam member you should have a SystemParametersInfo having the uiAction set to SPI_SETMOUSESPEED (if you want to change mouse speed).

Or, you could read this article which explains better than I do [pipe] :
P.S.: To import SystemParametersInfo API in C# use

[DllImport("user32.dll", CharSet=CharSet.Auto)]
public static extern int SystemParametersInfo ( int uAction , int uParam , string lpvParam , int fuWinIni);
 
Thanks very much for that - I was completly stumped;)

Problem sorted now...for anyone having similar trouble I will show you my example...

int nResult = WinAPI.SystemParametersInfo(WinAPI.SPI_SETMOUSESPEED,0,mouseSpeed,WinAPI.SPIF_SENDCHANGE);

the important thing to note is that lpvParam is not always a string, its an object and in the case of the mouse speed it is an int. between 1(slowest) and 20 where 10 is the default value.

use the following constants (uiAction) for getting/setting mouse speed...

//use constant SPI_GETMOUSESPEED => 112;
//use constant SPI_SETMOUSESPEED => 113;

once again - thanks for pointing me in the right direction boogyeman!
 
Well, you could import BroadcastSystemMessage and then broadcast a WM_SETTINGCHANGE to all recipients.

Note that a WM_SETTINGCHANGE will not affect any open command windows (cmd.exe). They won't pick up the new values -- you have to close/reopen them.

And yes, this did bite me.
:-(

Chip H.


____________________________________________________________________
Donate to Katrina relief:
If you want to get the best response to a question, please read FAQ222-2244 first
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top