本文整理汇总了C#中RegistryHive.ToString方法的典型用法代码示例。如果您正苦于以下问题:C# RegistryHive.ToString方法的具体用法?C# RegistryHive.ToString怎么用?C# RegistryHive.ToString使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类RegistryHive
的用法示例。
在下文中一共展示了RegistryHive.ToString方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: GetHiveKey
/// <summary>
/// Returns the key for a given registry hive.
/// </summary>
/// <param name="hive">The registry hive to return the key for.</param>
/// <returns>
/// The key for a given registry hive.
/// </returns>
protected RegistryKey GetHiveKey(RegistryHive hive)
{
switch (hive)
{
case RegistryHive.LocalMachine:
return Registry.LocalMachine;
case RegistryHive.Users:
return Registry.Users;
case RegistryHive.CurrentUser:
return Registry.CurrentUser;
case RegistryHive.ClassesRoot:
return Registry.ClassesRoot;
default:
Log(Level.Verbose, "Registry not found for {0}.", hive.ToString());
return null;
}
}
示例2: GetHiveName
static string GetHiveName (RegistryHive hive)
{
switch (hive) {
case RegistryHive.ClassesRoot:
return "HKEY_CLASSES_ROOT";
case RegistryHive.CurrentConfig:
return "HKEY_CURRENT_CONFIG";
case RegistryHive.CurrentUser:
return "HKEY_CURRENT_USER";
case RegistryHive.DynData:
return "HKEY_DYN_DATA";
case RegistryHive.LocalMachine:
return "HKEY_LOCAL_MACHINE";
case RegistryHive.PerformanceData:
return "HKEY_PERFORMANCE_DATA";
case RegistryHive.Users:
return "HKEY_USERS";
}
throw new NotImplementedException (string.Format (
"Registry hive '{0}' is not implemented.", hive.ToString ()));
}
示例3: OpenRegKey
/// ------------------------------------------------------------------------------------
/// <summary>
/// Open the registry key. If the key doesn't exist it will be created.
/// </summary>
/// <param name="key">Registry sub key</param>
/// <param name="hive">Registry hive</param>
/// <returns>registry key</returns>
/// ------------------------------------------------------------------------------------
protected RegistryKey OpenRegKey(string key, RegistryHive hive)
{
Log(Level.Verbose, "Opening {0}:{1}", hive.ToString(), key);
RegistryKey returnkey = GetHiveKey(hive).CreateSubKey(key);
if(returnkey != null)
{
return returnkey;
}
throw new BuildException(String.Format(CultureInfo.InvariantCulture,
"Registry Path Not Found! - key='{0}';hive='{1}';", key, hive));
}
示例4: GetRegistryKeyEffectiveRights
/// <summary>
/// Returns the ACL Access Mask for a user on registry key.
/// </summary>
/// <param name="targetInfo">The target info object. For Windows Authentication, the credentials must be null or empty.</param>
/// <param name="hive">The hive of registry key.</param>
/// <param name="registryKey">The path of registry key without hive value.</param>
/// <param name="userSID">The unique user security identifier.</param>
/// <returns>Access Mask as unassigned integer.</returns>
public virtual uint GetRegistryKeyEffectiveRights(
TargetInfo targetInfo, RegistryHive hive, string registryKey, string userSID)
{
IntPtr token = LogOn(targetInfo);
var person = WindowsIdentity.Impersonate(token);
var result = this.GetUserDaclForRegistryKeyOnTarget(
targetInfo, hive.ToString(), registryKey, userSID);
person.Undo();
return result;
}
示例5: LookupRegKey
/// <summary>
/// Returns the hive for a given key.
/// </summary>
/// <param name="key"></param>
/// <param name="registries"></param>
/// <returns>
/// The hive for a given key.
/// </returns>
protected RegistryKey LookupRegKey(string key, RegistryHive[] registries) {
foreach (RegistryHive hive in registries) {
Log(Level.Verbose, "Opening {0}:{1}.", hive.ToString(), key);
RegistryKey returnkey = GetHiveKey(hive).OpenSubKey(key, false);
if (returnkey != null) {
return returnkey;
}
}
throw new BuildException(string.Format(CultureInfo.InvariantCulture,
"Registry Path Not Found! - key='{0}';hive='{1}';", key,
registries.ToString()));
}
示例6: GetHiveKey
/// ------------------------------------------------------------------------------------
/// <summary>
/// Returns the registry key that corresponds to the passed in hive
/// </summary>
/// ------------------------------------------------------------------------------------
protected RegistryKey GetHiveKey(RegistryHive hive)
{
switch (hive)
{
case RegistryHive.LocalMachine:
return Registry.LocalMachine;
case RegistryHive.Users:
return Registry.Users;
case RegistryHive.CurrentUser:
return Registry.CurrentUser;
case RegistryHive.ClassesRoot:
return Registry.ClassesRoot;
default:
Log.LogWarning("WriteRegistry: registry not found for hive='{0}'.", hive.ToString());
return null;
}
}
示例7: OpenRegKey
/// ------------------------------------------------------------------------------------
/// <summary>
/// Open the registry key. If the key doesn't exist it will be created.
/// </summary>
/// ------------------------------------------------------------------------------------
protected RegistryKey OpenRegKey(string key, RegistryHive hive)
{
Log.LogMessage(MessageImportance.Low, "Opening {0}:{1}", hive.ToString(), key);
return GetHiveKey(hive).CreateSubKey(key);
}