Desktop10.X有多個版本,不同版本的注冊表路徑不一致,注冊表中可能殘留多個版本的注冊信息;也可能沒有Desktop,而是Engine。其實可以通過RuntimeManager.ActiveRuntime的屬性開判斷版本、產品類型、甚至安裝路徑等。
/// <summary> /// 修改滾輪方向 /// </summary> /// <param name="flag">0:向前表示放大(常規習慣);1:向前表示縮小</param> public static void ModifyWheel(int flag = 0) { string path = @"Software\ESRI\" + RuntimeManager.ActiveRuntime.Product + RuntimeManager.ActiveRuntime.Version + @"\ArcMap\Settings" ; RegistryKey setKey = Registry.CurrentUser.OpenSubKey(path, true) ?? Registry.CurrentUser.CreateSubKey(path); setKey?.SetValue("ReverseMouseWheel", flag, RegistryValueKind.DWord); }
如果綁定ProductCode.Engine許可,路徑為\Software\ESRI\Engine10.2\ArcMap\Settings;如果綁定ProductCode.Desktop許可,路徑為\Software\ESRI\ Desktop10.2\ArcMap\Settings