There are some settings that I need to be able to set at runtime, without a reboot. Using X-Mouse Controls as a guide, I've found a way to programmatically use SystemParametersInfo()
to set up active window tracking (SPI_SET_ACTIVEWINDOWTRACKING
), not raising windows on focus (SPI_SET_ACTIVEWNDTRKZORDER
), and the active window tracking timeout (SPI_ACTIVEWNDTRKTIMEOUT
).
All three of these settings are available through registry keys, but altering the values in the registry would necessitate a reboot. Using the SystemParamtersInfo()
call on the other hand, obviates this reboot.
Here's an example of one of the calls:
public static void SetActiveWindowTracking(bool enabled)
{
bool result = NativeMethods.SystemParametersInfo((uint) SPI.SPI_SETACTIVEWINDOWTRACKING, UiParamNoOp, enabled.AsUIntPtr(), SpifWrite);
if (!result)
{
throw new Win32Exception(Marshal.GetLastWin32Error());
}
}
The next setting I want to tackle is disabling Bluetooth absolute volume. This setting is available in the registry, at HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Bluetooth\Audio\AVRCP\CT
. However, if I simply alter this value, I will have to reboot to enable my new setting. I am interested in altering this setting without rebooting, similar to the three settings above. Is there a function I can call, either SystemParametersInfo()
, or something similar, which will give me the capability of twiddling this setting without a reboot?
BTW, I'm working in C♯ with WPF. I am, however, open to other solutions.
Thanks!
Take a look at this Windows Audio Core lib for options and I added 3 ways to do it.
Just execute this as a batch file/CMD at Startup or here on SO