1. 程式人生 > >ArcGIS鼠標滾輪方向之代碼篇

ArcGIS鼠標滾輪方向之代碼篇

ren 分享 縮小 pre val run bubuko image creat

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

技術分享圖片

ArcGIS鼠標滾輪方向之代碼篇