private static void OnRegChanged(object sender, EventArgs e) { RegistryKey key = Registry.CurrentUser; object accelVal = null; log.Debug("HKCU\\Control Panel\\Mouse key change detected"); try { key = key.OpenSubKey("Control Panel\\Mouse", false); if (key != null) { accelVal = key.GetValue("MouseSensitivity"); log.Debug("MouseSensitivity: " + accelVal.ToString()); } } catch (Exception ex) { log.Error("Exception reading Mouse key", ex); } try { if (accelVal != null) { hostService.SetAcceleration(Convert.ToInt32(accelVal.ToString())); } } catch (Exception ex) { log.Error("Failed to set accleration: ", ex); } }