Further digging helped me combine the following as a way to turn touch on and off throughout the system. If someone knows how to do this in any of the other three ways, I will still be grateful for these answers.
The main steps: check the current status of the registry, change it if necessary (and then update the system to recognize the change), and indicate the initial state for recovery if the program needs to exit.
Thanks to the posters in these two links for education.
public MainWindow(){ InitializeComponent(); RegistryKey regKey = Registry.CurrentUser; regKey = regKey.OpenSubKey(@"Software\Microsoft\Wisp\Touch", true); string currKey = regKey.GetValue("TouchGate").ToString(); if (currKey == "1") { regKey.SetValue("TouchGate", 0x00000000); User32Utils.Notify_SettingChange(); UserConfig.TGate = "1"; } regKey.Close(); ... } public static class UserConfig { public static string TGate { get; set; } ... } private void MainWindow_Closing(object sender, System.ComponentModel.CancelEventArgs e){ ... if (UserConfig.TGate == "1") { RegistryKey regKey = Registry.CurrentUser; regKey = regKey.OpenSubKey(@"Software\Microsoft\Wisp\Touch", true); regKey.SetValue("TouchGate", 0x00000001); User32Utils.Notify_SettingChange(); regKey.Close(); } }
source share