本文整理汇总了C#中Microsoft.OpenSubKey方法的典型用法代码示例。如果您正苦于以下问题:C# Microsoft.OpenSubKey方法的具体用法?C# Microsoft.OpenSubKey怎么用?C# Microsoft.OpenSubKey使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Microsoft
的用法示例。
在下文中一共展示了Microsoft.OpenSubKey方法的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: DeleteRegValue
public static void DeleteRegValue( Microsoft.Win32.RegistryKey hkey, string vname )
{
using ( RegistryKey key = hkey.OpenSubKey( RazorRegPath, true ) )
{
key.DeleteValue( vname, false );
}
}
示例2: ClearReg
//[RegistryPermissionAttribute(SecurityAction.PermitOnly, Write = @"HKEY_CURRENT_USER\SOFTWARE\DBFConvert")]
//[RegistryPermissionAttribute(SecurityAction.PermitOnly, Write = @"HKEY_LOCAL_MACHINE\SOFTWARE\DBFConvert")]
private void ClearReg(Microsoft.Win32.RegistryKey localRegKey, Microsoft.Win32.RegistryKey userRegKey)
{
string[] subkeys = localRegKey.OpenSubKey(regPath,true).GetSubKeyNames();
foreach (string key in subkeys)
{
localRegKey.DeleteSubKeyTree(key);
}
subkeys = userRegKey.OpenSubKey(regPath,true).GetSubKeyNames();
foreach (string key in subkeys)
{
localRegKey.DeleteSubKeyTree(key);
}
}
示例3: GetRegString
public static string GetRegString( Microsoft.Win32.RegistryKey hkey, string vname )
{
try
{
RegistryKey key = hkey.OpenSubKey( RazorRegPath ) ;
if ( key == null )
{
key = hkey.CreateSubKey( RazorRegPath );
if ( key == null )
return null;
}
string v = key.GetValue( vname ) as string;
if ( v == null )
return null;
return v.Trim();
}
catch
{
return null;
}
}
示例4: CopyKeyRecursive
private static void CopyKeyRecursive(Microsoft.Win32.RegistryKey sourceKey, Microsoft.Win32.RegistryKey destKey)
{
foreach (string ValueName in sourceKey.GetValueNames()) {
object Val = sourceKey.GetValue(ValueName);
destKey.SetValue(ValueName, Val, sourceKey.GetValueKind(ValueName));
}
foreach (string SubKeyName in sourceKey.GetSubKeyNames()) {
using (Microsoft.Win32.RegistryKey sourceSubKey = sourceKey.OpenSubKey(SubKeyName, false))
using (Microsoft.Win32.RegistryKey destSubKey = destKey.CreateSubKey(SubKeyName)) {
CopyKeyRecursive(sourceSubKey, destSubKey);
}
}
}
示例5: RenameSubKey
public static void RenameSubKey(Microsoft.Win32.RegistryKey parentKey, string subKeyName, string newSubKeyName)
{
using (Microsoft.Win32.RegistryKey Src = parentKey.OpenSubKey(subKeyName, false))
using (Microsoft.Win32.RegistryKey Dest = parentKey.CreateSubKey(newSubKeyName)) {
CopyKeyRecursive(Src, Dest);
}
parentKey.DeleteSubKeyTree(subKeyName);
}
示例6: FindByDisplayName
private static string FindByDisplayName(Microsoft.Win32.RegistryKey parentKey, string name)
{
string[] nameList = parentKey.GetSubKeyNames();
for (int i = 0; i < nameList.Length; i++)
{
Microsoft.Win32.RegistryKey regKey = parentKey.OpenSubKey(nameList[i]);
try
{
if (regKey.GetValue("DisplayName").ToString() == name)
{
return regKey.GetValue("InstallLocation").ToString();
}
else{
//Debug.Log(nameList[i] + ", " + regKey.Name + " : " + regKey.GetValue("InstallLocation").ToString());
}
}
catch {
//Debug.LogError ("AAA");
}
}
return "";
}
示例7: VerifyRegistryKeyPermission
/// <summary>
/// Verify that a specific user has access rights to a specific Registry Key
/// </summary>
/// <param name="userName">Name of the user to check for</param>
/// <param name="root">Root key for the registry key</param>
/// <param name="subKey">Registry key to check for</param>
/// <param name="rights">Expected access rights</param>
public static void VerifyRegistryKeyPermission(string userName, Microsoft.Win32.RegistryKey root, string subKey, RegistryRights rights)
{
RegistryKey registryKey = root.OpenSubKey(subKey);
RegistrySecurity registrySecurity = registryKey.GetAccessControl();
AuthorizationRuleCollection accessRules = registrySecurity.GetAccessRules(true, true, typeof(NTAccount));
foreach (RegistryAccessRule accessRule in accessRules)
{
if (userName.ToLowerInvariant().Equals(accessRule.IdentityReference.Value.ToLowerInvariant()))
{
if ((accessRule.RegistryRights & rights) == rights)
{
return;
}
}
}
Assert.True(false, string.Format("User '{0}' do not have the correct permessions to RegistryKey '{1}/{2}'.", userName, root.ToString(), subKey));
}
示例8: RemoveRegistryKeyPermission
/// <summary>
/// Remove Permissions on a Registry key
/// </summary>
/// <param name="userName">the user name to remove permissions for</param>
/// <param name="root">the root hive</param>
/// <param name="subKey">the key</param>
public static void RemoveRegistryKeyPermission(string userName, Microsoft.Win32.RegistryKey root, string subKey)
{
RegistryKey registryKey = root.OpenSubKey(subKey);
RegistrySecurity registrySecurity = registryKey.GetAccessControl();
AuthorizationRuleCollection accessRules = registrySecurity.GetAccessRules(true, true, typeof(NTAccount));
foreach (RegistryAccessRule accessRule in accessRules)
{
if (userName.ToLowerInvariant().Equals(accessRule.IdentityReference.Value.ToLowerInvariant()))
{
registrySecurity.RemoveAccessRule(accessRule);
}
}
}
示例9: Load
/* ----------------------------------------------------------------- */
///
/// Load
///
/// <summary>
/// ユーザ毎の設定情報をレジストリからロードします。
/// </summary>
///
/// <remarks>
/// LastCheckUpdate の項目のみ、保存場所が異なるので別途処理を行って
/// います。
/// </remarks>
///
/* ----------------------------------------------------------------- */
public bool Load(Microsoft.Win32.RegistryKey root)
{
try
{
using (var subkey = root.OpenSubKey(_RegRoot, false))
{
using (var child = subkey.OpenSubKey(_RegVersion, false))
{
var document = new CubePdf.Settings.Document();
document.Read(child);
Load(document);
}
var date = subkey.GetValue(_RegLastCheck, string.Empty) as string;
if (!string.IsNullOrEmpty(date)) _lastcheck = DateTime.Parse(date as string);
}
return true;
}
catch (Exception /* err */) { return false; }
}
示例10: GetVsPackages
public void GetVsPackages(Microsoft.Win32.RegistryKey hiveRoot, Microsoft.Win32.RegistryKey editorKey, string editorExt)
{
if ((extension == null) || (System.StringComparer.OrdinalIgnoreCase.Compare(editorExt, extension) == 0))
{
string s = editorKey.GetValue("Package") as string;
if (!System.String.IsNullOrEmpty(s))
{
using (Microsoft.Win32.RegistryKey registryKey = hiveRoot.OpenSubKey("Packages\\" + s))
{
if ((registryKey != null) && !editors.ContainsKey(registryKey.Name))
editors.Add(registryKey.Name, new VsPackageInfo(registryKey));
}
}
}
}
示例11: LoadExtensions
private static void LoadExtensions(Microsoft.Win32.RegistryKey hiveRoot, Helper registry)
{
if (hiveRoot == null)
return;
using (Microsoft.Win32.RegistryKey registryKey = hiveRoot.OpenSubKey("Editors"))
{
if (registryKey == null)
return;
string[] sArr = registryKey.GetSubKeyNames();
foreach (string keyName in sArr)
{
using (Microsoft.Win32.RegistryKey registrySubKey = registryKey.OpenSubKey(keyName))
{
if (registrySubKey == null)
continue;
using (Microsoft.Win32.RegistryKey registryKeyExtensions = registrySubKey.OpenSubKey("Extensions"))
{
if (registryKeyExtensions == null)
continue;
string[] sArrExt = registryKeyExtensions.GetValueNames();
foreach (string n in sArrExt)
{
char[] chArr = new char[] { '.', ' ' };
string result = n.Trim(chArr).ToUpperInvariant();
registry.GetVsPackages(hiveRoot, registrySubKey, result);
}
}
}
}
}
}
示例12: DoesSoftwareKeyExist
DoesSoftwareKeyExist(
string path,
Microsoft.Win32.RegistryKey registryArea,
bool query32Bit)
{
if (!OSUtilities.IsWindowsHosting)
{
return false;
}
var exists = true;
using (var key = registryArea.OpenSubKey(SoftwareKeyPath(path, query32Bit)))
{
if (null == key)
{
exists = false;
}
}
return exists;
}
示例13: OpenSoftwareKey
OpenSoftwareKey(
string path,
Microsoft.Win32.RegistryKey registryArea,
bool query32Bit)
{
if (!OSUtilities.IsWindowsHosting)
{
return null;
}
var keyPath = SoftwareKeyPath(path, query32Bit);
var key = registryArea.OpenSubKey(keyPath);
if (null == key)
{
Log.DebugMessage("Registry key '{0}' on {1} not found", keyPath, registryArea.Name);
}
return key;
}