/// <summary> /// Retrieves the file system path to the root of the specified GPO section. /// The path is in UNC format. /// </summary> public override string GetPathTo(GroupPolicySection section) { StringBuilder sb = new StringBuilder(maxLength); trycatch(() => instance.GetFileSysPath((uint)section, sb, maxLength), "Unable to retrieve path to section '{0}'", Enum.GetName(typeof(GroupPolicySection), section)); return(sb.ToString()); }
/// <summary> /// Retrieves the root of the registry key for the specified GPO section /// </summary> public RegistryKey GetRootRegistryKey(GroupPolicySection section) { IntPtr key = default(IntPtr); trycatch(() => instance.GetRegistryKey((uint)section, out key), "Unable to get section '{0}'", Enum.GetName(typeof(GroupPolicySection), section)); var safeHandle = new SafeRegistryHandle(key, true); return(RegistryKey.FromHandle(safeHandle)); }
/// <summary> /// Retrieves the file system path to the root of the specified GPO section. /// The path is in UNC format. /// </summary> public override string GetPathTo(GroupPolicySection section) { var sb = new StringBuilder(MaxLength); var result = Instance.GetFileSysPath((uint)section, sb, MaxLength); if (result != 0) { throw new Exception(string.Format("Unable to retrieve path to section '{0}'", Enum.GetName(typeof(GroupPolicySection), section))); } return(sb.ToString()); }
public RegistryKey GetRootRegistryKey(GroupPolicySection section) { IntPtr key; var result = Instance.GetRegistryKey((uint)section, out key); if (result != 0) { throw new Exception(string.Format("Unable to get section '{0}'", Enum.GetName(typeof(GroupPolicySection), section))); } var handle = new SafeRegistryHandle(key, true); return RegistryKey.FromHandle(handle, RegistryView.Default); }
public static string Key(string registryInformation, out string value, out GroupPolicySection section) { // Parse parameter of format HKCU\Software\Policies\Microsoft\Windows\Personalization!NoChangingSoundScheme string[] split = registryInformation.Split('!'); string key = split[0]; string hive = key.Substring(0, key.IndexOf('\\')); key = key.Substring(key.IndexOf('\\') + 1); value = split[1]; if (hive.Equals(@"HKLM", StringComparison.OrdinalIgnoreCase) || hive.Equals(@"HKEY_LOCAL_MACHINE", StringComparison.OrdinalIgnoreCase)) { section = GroupPolicySection.Machine; } else { section = GroupPolicySection.User; } return key; }
public abstract string GetPathTo(GroupPolicySection section);