Editing Registry [closed]
How can I edit registry settings which would take place immediatly without a restart/log off using c# ?
Thank you!
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.
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.
精彩评论