-4

How can I edit registry settings which would take place immediatly without a restart/log off using c# ?

Thank you!

svick
  • 236,525
  • 50
  • 385
  • 514
  • Microsoft.Win32.Registry – L.B Oct 09 '11 at 14:07
  • 1
    Your question does not make sense as asked. The registry has nothing to do with rebooting; all changes are applied immediately. You're asking for a Windows API function to change the setting. – SLaks Oct 09 '11 at 14:06

2 Answers2

5

You can edit the registry by using Registry or RegistryKey classes.

That changes the values in the registry immediately. But when the actual change takes place depends on what exactly that change is. And some of them aren't possible without restarting the computer or logging off and on the current user.

svick
  • 236,525
  • 50
  • 385
  • 514
0

Your mistake is that you're using the registry. You should use the appropriate APIs to change settings instead of using the registry directly.

For most windows settings SystemParametersInfo is used to change the settings. Passing SPIF_SENDCHANGE the last parameters makes the change take effect immediately. And to make the change permanent you need to combine it with SPIF_UPDATEINIFILE.

I don't know if this supports the settings you want to change, since you didn't specify what you want to do. It might be possible to change some settings directly in the registry and then use SystemParametersInfo to notify the applications, that use this setting, of this change. But this sounds like API abuse and should only be done if you find no better alternative.

CodesInChaos
  • 106,488
  • 23
  • 218
  • 262