Control Panel Settings from Command Line

不羁的心 提交于 2019-12-24 11:47:34

问题


I'm looking for a way to make a Registry Change take affect right away. Specifically the value I want to touch is:

HKEY_CURRENT_USER/Control\ Panel/Desktop/WindowArrangementActive

When you change this setting directly from the Control Panel it takes effect immediately, but when I'm changing it manually, it is not registered before rebooting.

I'm trying to make a script to disable/enable window snapping in Windows 10.

I've currently tried running the following command after the change with no luck:

RUNDLL32.EXE USER32.DLL,UpdatePerUserSystemParameters ,1 ,True


回答1:


I ended up getting the job done in C# using the SystemParametersInfo:

[DllImport("user32.dll", EntryPoint = "SystemParametersInfo")]
public static extern bool SystemParametersInfo(int uiAction, int uiParam, IntPtr pvParam, int fWinIni);

and calling it with the following params:

SystemParametersInfo(0x0083, 0, IntPtr.Zero, 0x001A);

The final param is the one informing the system that the variable has changed in accordance with this documentation by Microsoft:

https://msdn.microsoft.com/en-us/library/windows/desktop/ms725497(v=vs.85).aspx



来源:https://stackoverflow.com/questions/35252154/control-panel-settings-from-command-line

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!