本文整理汇总了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;
}
示例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;
}
示例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;
}
示例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;
}