当前位置: 首页>>代码示例>>C#>>正文


C# IRegistry.OpenBaseKey方法代码示例

本文整理汇总了C#中IRegistry.OpenBaseKey方法的典型用法代码示例。如果您正苦于以下问题:C# IRegistry.OpenBaseKey方法的具体用法?C# IRegistry.OpenBaseKey怎么用?C# IRegistry.OpenBaseKey使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在IRegistry的用法示例。


在下文中一共展示了IRegistry.OpenBaseKey方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: GetMicrosoftRClientInfo

        public static IRInterpreterInfo GetMicrosoftRClientInfo(IRegistry registry = null, IFileSystem fileSystem = null) {
            registry = registry ?? new RegistryImpl();
            fileSystem = fileSystem ?? new FileSystem();

            // If yes, check 32-bit registry for R engine installed by the R Server.
            // TODO: remove this when MRS starts writing 64-bit keys.
            if (IsMRCInstalledInSql(registry)) {
                using (IRegistryKey hklm = registry.OpenBaseKey(RegistryHive.LocalMachine, RegistryView.Registry32)) {
                    try {
                        using (var key = hklm.OpenSubKey(@"SOFTWARE\R-core\R64")) {
                            foreach (var keyName in key.GetSubKeyNames()) {
                                using (var rsKey = key.OpenSubKey(keyName)) {
                                    try {
                                        var path = (string)rsKey?.GetValue("InstallPath");
                                        if (!string.IsNullOrEmpty(path) && path.Contains(_rServer)) {
                                            var info = new RInterpreterInfo(string.Empty, path);
                                            if (info.VerifyInstallation(new SupportedRVersionRange(), fileSystem)) {
                                                return new RInterpreterInfo(Invariant($"Microsoft R Client (SQL) {info.Version.Major}.{info.Version.Minor}.{info.Version.Build}"), info.InstallPath);
                                            }
                                        }
                                    } catch (Exception) { }
                                }
                            }
                        }
                    } catch (Exception) { }
                }
            }

            return null;
        }
开发者ID:Microsoft,项目名称:RTVS,代码行数:30,代码来源:SqlRClientInstallation.cs

示例2: IsMRCInstalledInSql

 private static bool IsMRCInstalledInSql(IRegistry registry = null) {
     bool mrsInstalled = false;
     try {
         using (var hklm = registry.OpenBaseKey(RegistryHive.LocalMachine, RegistryView.Registry64)) {
             using (var key = hklm.OpenSubKey(@"SOFTWARE\Microsoft\Microsoft SQL Server\130\sql_shared_mr")) {
                 var path = (string)key?.GetValue("Path");
                 if (!string.IsNullOrEmpty(path) && path.Contains(_rServer)) {
                     mrsInstalled = true;
                 }
             }
         }
     } catch (Exception) { }
     return mrsInstalled;
 }
开发者ID:Microsoft,项目名称:RTVS,代码行数:14,代码来源:SqlRClientInstallation.cs

示例3: GetRClientPath

        public static string GetRClientPath(IRegistry registry = null) {
            registry = registry ?? new RegistryImpl();
            try {
                using (var hkcu = registry.OpenBaseKey(RegistryHive.LocalMachine, RegistryView.Registry64)) {
                    using (var key = hkcu.OpenSubKey(_rClientKey)) {
                        string path = (string)key.GetValue("Path");
                        if (!string.IsNullOrEmpty(path)) {
                            return Path.Combine(path, _rServer + "\\");
                        }
                    }
                }
            } catch (Exception) { }

            return string.Empty;
        }
开发者ID:Microsoft,项目名称:RTVS,代码行数:15,代码来源:SqlRClientInstallation.cs

示例4: AskUserSwitchToRClient

        private static bool AskUserSwitchToRClient(IRegistry registry = null) {
            registry = registry ?? new RegistryImpl();
            try {
                using (var hkcu = registry.OpenBaseKey(RegistryHive.CurrentUser, RegistryView.Registry64)) {
                    using (var key = hkcu.OpenSubKey(rtvsKey + "\\" + Toolset.Version, writable: true)) {
                        object value = key.GetValue("RClientPrompt");
                        if (value == null) {
                            key.SetValue("RClientPrompt", 0);
                            return true;
                        }
                    }
                }
            } catch (Exception ex) when (!ex.IsCriticalException()) { }

            return false;
        }
开发者ID:Microsoft,项目名称:RTVS,代码行数:16,代码来源:MicrosoftRClient.cs


注:本文中的IRegistry.OpenBaseKey方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。