GroupPolicyObject.GetRegistrySetting Method (RegistryHive, String, String)


Retrieves the registry-based policy setting for the specified registry value from the Group Policy object (GPO).

Namespace:   Microsoft.GroupPolicy
Assembly:  Microsoft.GroupPolicy.Management.Interop (in Microsoft.GroupPolicy.Management.Interop.dll)


public PolicyRegistrySetting GetRegistrySetting(
    RegistryHive hive,
    string keyPath,
    string valueName
PolicyRegistrySetting^ GetRegistrySetting(
    RegistryHive hive,
    String^ keyPath,
    String^ valueName
member GetRegistrySetting : 
        hive:RegistryHive *
        keyPath:string *
        valueName:string -> PolicyRegistrySetting
Public Function GetRegistrySetting (
    hive As RegistryHive,
    keyPath As String,
    valueName As String
) As PolicyRegistrySetting


  • hive
    Type: Microsoft.Win32.RegistryHive

    One of the RegistryHive values that specifies the registry hive for which to retrieve the registry-based policy setting. Specify CurrentUser to retrieve the policy setting from User Configuration. Specify LocalMachine to retrieve the policy setting from Computer Configuration. No other values are supported.

  • keyPath
    Type: System.String

    The path to the registry key for which to retrieve the registry-based policy setting.

  • valueName
    Type: System.String

    The name of the value for which to retrieve the registry-based policy setting. Specify an empty string (“”) for the default value.

Return Value

Type: Microsoft.GroupPolicy.PolicyRegistrySetting

Returns PolicyRegistrySetting. The registry-based policy setting.


Exception Condition

A registry-based policy setting does not exist for the specified registry value.


The keyPath parameter or the valueName parameter is null.


hive is not a supported RegistryHive value.


The GroupPolicyObject is disposed.


The registry key for which to delete the registry-based policy setting is specified by a combination of the hive and the keyPath parameters.

See Also

GroupPolicyObject Class
Microsoft.GroupPolicy Namespace

Return to top