本文整理汇总了C#中RegistryView类的典型用法代码示例。如果您正苦于以下问题:C# RegistryView类的具体用法?C# RegistryView怎么用?C# RegistryView使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
RegistryView类属于命名空间,在下文中一共展示了RegistryView类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C#代码示例。
示例1: ReadLicenseFromRegistry
string ReadLicenseFromRegistry(RegistryView view)
{
try
{
using (var rootKey = RegistryKey.OpenBaseKey(RegistryHive.CurrentUser, view))
using (var registryKey = rootKey.OpenSubKey(keyPath))
{
if (registryKey == null)
{
return null;
}
var licenseValue = registryKey.GetValue("License", null);
if (licenseValue is string[])
{
return string.Join(" ", (string[])licenseValue);
}
return (string)licenseValue;
}
}
catch
{
return null;
}
}
开发者ID:Particular,项目名称:ServiceInsight,代码行数:26,代码来源:LicenseSourceHKCURegKey.cs
示例2: RegistryKeyExists
static bool RegistryKeyExists(string keyName, RegistryView registryView)
{
var localKey = RegistryKey.OpenBaseKey(RegistryHive.LocalMachine, registryView);
localKey = localKey.OpenSubKey(keyName);
return localKey != null;
}
开发者ID:robdmoore,项目名称:GitVersion,代码行数:7,代码来源:ContinuaCi.cs
示例3: ReadKey
public static object ReadKey(RegistryHive hive, RegistryView view, string subkey, string name)
{
// open root
RegistryKey rootKey = Microsoft.Win32.RegistryKey.OpenBaseKey(hive, view);
if (rootKey == null)
{
return null;
}
// look for key
RegistryKey key = rootKey.OpenSubKey(subkey);
if (key == null)
{
return null;
}
// look for value
object value = key.GetValue(name);
if (value == null)
{
return null;
}
return value;
}
开发者ID:aredon,项目名称:MPExtended,代码行数:25,代码来源:RegistryReader.cs
示例4: FromHandle
public IRegistryKey FromHandle(
SafeRegistryHandle handle,
RegistryView view
)
{
return new RegistryKeyWrap(RegistryKey.FromHandle(handle, view));
}
开发者ID:sign42,项目名称:SystemWrapper,代码行数:7,代码来源:RegistryKeySystem.cs
示例5: OpenBaseKey
public IRegistryKey OpenBaseKey(
RegistryHive hKey,
RegistryView view
)
{
return new RegistryKeyWrap(RegistryKey.OpenBaseKey(hKey, view));
}
开发者ID:sign42,项目名称:SystemWrapper,代码行数:7,代码来源:RegistryKeySystem.cs
示例6: add_key
private void add_key(IList<RegistryKey> keys, RegistryHive hive, RegistryView view)
{
FaultTolerance.try_catch_with_logging_exception(
() => keys.Add(RegistryKey.OpenBaseKey(hive, view)),
"Could not open registry hive '{0}' for view '{1}'".format_with(hive.to_string(), view.to_string()),
logWarningInsteadOfError: true);
}
开发者ID:secretGeek,项目名称:choco,代码行数:7,代码来源:RegistryService.cs
示例7: Init
public static void Init(RegistryView settingsRoot, IDictionary<string, IEnumerable<string>> options)
{
if (BitlySettings == null) {
BitlySettings = settingsRoot["bitly"];
bitlyUsername = BitlySettings["#username"].StringValue;
bitlySecret = BitlySettings["#password"].EncryptedStringValue;
foreach (var arg in options.Keys) {
var argumentParameters = options[arg];
var last = argumentParameters.LastOrDefault();
switch (arg) {
case "bitly-username":
bitlyUsername = last;
BitlySettings["#username"].StringValue = bitlyUsername;
break;
case "bitly-secret":
bitlySecret = last;
BitlySettings["#password"].EncryptedStringValue = bitlySecret;
break;
}
}
}
}
开发者ID:virmitio,项目名称:devtools,代码行数:26,代码来源:Utility.cs
示例8:
public RegistrySettingsProvider
(RegistryHive hKey, RegistryView view = RegistryView.Default, string baseKey = null)
{
this.hKey = hKey;
this.view = view;
this.baseKey = baseKey ?? ProductInfo.Company + "\\" + ProductInfo.Product;
}
开发者ID:jammycakes,项目名称:dolstagis.ideas,代码行数:7,代码来源:RegistrySettingsProvider.cs
示例9: OpenRegistryHive
/// <summary>
/// Given a registry path, locate the correct root key and return the relative path. For example, when the user gives the absolute registry path
///
/// HKEY_LOCAL_MACHINE\Software\Microsoft
///
/// you really have two parts: HKEY_LOCAL_MACHINE is a "registry hive" root, and "Software\Microsoft" the relative path.
/// </summary>
/// <param name="rootPath">absolute registry path</param>
/// <param name="rootPathWithoutHive">Returns the relative path</param>
/// <param name="registryView">Type of registry you want to see (32-bit, 64-bit, default).</param>
/// <param name="remoteMachineName">Name of a remote machine. User must ensure that caller has sufficient privileges to access the key</param>
/// <returns>"registry hive" root</returns>
public static RegistryKey OpenRegistryHive(string rootPath, out string rootPathWithoutHive, RegistryView registryView, string remoteMachineName = null)
{
rootPathWithoutHive = "";
bool found = false;
foreach (string key in KnownHives.Keys)
{
if (rootPath.StartsWith(key+"\\", StringComparison.OrdinalIgnoreCase))
{
rootPathWithoutHive = rootPath.Substring(key.Length+1);
found = true;
}
if (rootPath.Equals(key, StringComparison.OrdinalIgnoreCase))
{
rootPathWithoutHive = rootPath.Substring(key.Length);
found = true;
}
if (found)
{
if (string.IsNullOrEmpty(remoteMachineName))
{
return RegistryKey.OpenBaseKey(KnownHives[key], registryView);
}
else
{
return RegistryKey.OpenRemoteBaseKey(KnownHives[key], remoteMachineName, registryView);
}
}
}
Trace.TraceWarning("'{0}' is not a well-formed registry path", rootPath);
return null;
}
开发者ID:therealjuanmartinez,项目名称:regdiff,代码行数:43,代码来源:Regis3.cs
示例10: ReadFromRegistry
LicenseSourceResult ReadFromRegistry(RegistryView view, string applicationName)
{
try
{
using (var rootKey = RegistryKey.OpenBaseKey(RegistryHive.LocalMachine, view))
using (var registryKey = rootKey.OpenSubKey(keyPath))
{
if (registryKey == null)
{
return ValidateLicense(null, applicationName);
}
var regValue = registryKey.GetValue("License", null);
var licenseText = (regValue is string[])
? string.Join(" ", (string[])regValue)
: (string)regValue;
return ValidateLicense(licenseText, applicationName);
}
}
catch (SecurityException)
{
return new LicenseSourceResult
{
Location = location,
Result = $"Insufficent rights to read license from {location}"
};
}
}
开发者ID:Particular,项目名称:ServiceInsight,代码行数:30,代码来源:LicenseSourceHKLMRegKey.cs
示例11: OpenRemoteBaseKey
public IRegistryKey OpenRemoteBaseKey(
RegistryHive hKey,
string machineName,
RegistryView view
)
{
return new RegistryKeyWrap(RegistryKey.OpenRemoteBaseKey(hKey, machineName, view));
}
开发者ID:sign42,项目名称:SystemWrapper,代码行数:8,代码来源:RegistryKeySystem.cs
示例12: DeleteKey
static void DeleteKey(RegistryHive hive, RegistryView view, string guid)
{
using (RegistryKey key = RegistryKey.OpenBaseKey(hive, view)) {
key.DeleteSubKey("Software\\Classes\\CLSID\\" + guid + "\\ProgId", false);
key.DeleteSubKey("Software\\Classes\\CLSID\\" + guid + "\\InProcServer32", false);
key.DeleteSubKey("Software\\Classes\\CLSID\\" + guid, false);
}
}
开发者ID:2594636985,项目名称:SharpDevelop,代码行数:8,代码来源:Registrar.cs
示例13: FindRegistryValueUnderKey
private static string FindRegistryValueUnderKey(string registryBaseKeyName, string registryKeyName, RegistryView registryView)
{
using (RegistryKey registryKey = RegistryKey.OpenBaseKey(RegistryHive.LocalMachine, registryView))
{
using (RegistryKey registryKey2 = registryKey.OpenSubKey(registryBaseKeyName))
{
return registryKey2?.GetValue(registryKeyName)?.ToString() ?? string.Empty;
}
}
}
开发者ID:jinjingcai2014,项目名称:il-repack,代码行数:10,代码来源:PeverifyHelper.cs
示例14: CreateKeys
static void CreateKeys(RegistryHive hive, RegistryView view, string guid, string libraryId, string classId, string path)
{
using (RegistryKey key = RegistryKey.OpenBaseKey(hive, view)) {
using (RegistryKey subKey = key.CreateSubKey("Software\\Classes\\CLSID\\" + guid))
subKey.SetValue(null, classId + " Class");
using (RegistryKey subKey = key.CreateSubKey("Software\\Classes\\CLSID\\" + guid + "\\InProcServer32"))
subKey.SetValue(null, path);
using (RegistryKey subKey = key.CreateSubKey("Software\\Classes\\CLSID\\" + guid + "\\ProgId"))
subKey.SetValue(null, libraryId + "." + classId);
}
}
开发者ID:2594636985,项目名称:SharpDevelop,代码行数:11,代码来源:Registrar.cs
示例15: ReadRegistry
static string ReadRegistry(RegistryView view, string keyName, string defaultValue)
{
using (var key = RegistryKey.OpenBaseKey(RegistryHive.LocalMachine, view).OpenSubKey(@"SOFTWARE\ParticularSoftware\ServiceBus"))
{
if (key == null)
{
return defaultValue;
}
return (string) key.GetValue(keyName, defaultValue);
}
}
开发者ID:Particular,项目名称:NServiceBus,代码行数:11,代码来源:RegistryReader.cs
示例16: RegisterTypeLib
public void RegisterTypeLib(System.Reflection.Assembly typeLib, RegistryView registryView )
{
var reg = ComClrInfoFactory.CreateTypeLib(typeLib);
#if NET35
throw new NotImplementedException("Need to backport 4.0 methods");
#else
var root = RegistryKey.OpenBaseKey(RegistryHive.CurrentUser, registryView);
var classes = root.CreateSubKey(CLASSES);
registerTypeLib(classes, reg);
#endif
}
开发者ID:tablesmit,项目名称:NRegFreeCom,代码行数:11,代码来源:UserRegAsm.cs
示例17: RegistryImporter
/// <summary>
/// The default constructor takes a registry root path encoded as a string (for example, HKEY_LOCAL_MACHINE\Software\Microsoft)
/// and reads everything under it.
/// </summary>
/// <param name="rootPath">Root path</param>
/// <param name="registryView">Type of registry you want to see (32-bit, 64-bit, default).</param>
public RegistryImporter(string rootPath, RegistryView registryView)
{
Result = new RegKeyEntry(null, rootPath);
string rootPathWithoutHive;
RegistryKey rootKey = Regis3.OpenRegistryHive(rootPath, out rootPathWithoutHive, registryView);
using (RegistryKey key = rootKey.OpenSubKey(rootPathWithoutHive))
{
ImportRecursive(Result, key);
}
}
开发者ID:therealjuanmartinez,项目名称:regdiff,代码行数:17,代码来源:RegistryImporter.cs
示例18: UnregisterInProcServer
public void UnregisterInProcServer(Type t, RegistryView registryView = RegistryView.Default)
{
var reg = ComClrInfoFactory.CreateClass(t);
#if NET35
throw new NotImplementedException("Need to backport 4.0 methods");
#else
var root = RegistryKey.OpenBaseKey(RegistryHive.LocalMachine, registryView);
var classes = root.CreateSubKey(CLASSES);
unregisterInProcServer(classes, reg);
#endif
}
开发者ID:tablesmit,项目名称:NRegFreeCom,代码行数:11,代码来源:MachineRegAsm.cs
示例19: UnregisterInterface
public void UnregisterInterface(Type type, RegistryView registryView = RegistryView.Default)
{
var reg = ComClrInfoFactory.CreateInterface(type);
#if NET35
throw new NotImplementedException("Need to backport 4.0 methods");
#else
var root = RegistryKey.OpenBaseKey(RegistryHive.CurrentUser, registryView);
var classes = root.CreateSubKey(CLASSES);
unregisterInterface(classes, reg);
#endif
}
开发者ID:tablesmit,项目名称:NRegFreeCom,代码行数:11,代码来源:UserRegAsm.cs
示例20: GetDataAndConstructOdbcObject
private ODBC GetDataAndConstructOdbcObject(RegistryHive hiveToUse, RegistryView viewToUse, string stringToReplace, string path, string odbcKey)
{
RegistryKey odbcReg = RegistryKey.OpenBaseKey(hiveToUse, viewToUse);
odbcReg = odbcReg.OpenSubKey(path);
odbcReg = odbcReg.OpenSubKey(odbcKey);
string server = (string)odbcReg.GetValue("server");
string driver = (string)odbcReg.GetValue("driver");
string name = odbcReg.Name.Replace(stringToReplace + "\\" + path + "\\", "");
string dsn = name;
ODBC odbcObject = new ODBC(dsn, driver, server);
return odbcObject;
}
开发者ID:SamuelCox,项目名称:ODBCInfoGatherer,代码行数:12,代码来源:ConnectionManager.cs
注:本文中的RegistryView类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论