RegistryValueOptions Enum

Definition

Specifies optional behavior when retrieving name/value pairs from a registry key.

This enumeration supports a bitwise combination of its member values.

C#
[System.Flags]
public enum RegistryValueOptions
Inheritance
RegistryValueOptions
Attributes

Fields

Name Value Description
None 0

No optional behavior is specified.

DoNotExpandEnvironmentNames 1

A value of type ExpandString is retrieved without expanding its embedded environment variables.

Examples

The following code sample creates a test key, adds a value with an embedded environment variable, and retrieves the value in both expanded and unexpanded forms.

C#
using System;
using Microsoft.Win32;
using Microsoft.VisualBasic;

public class Example
{
    public static void Main()
    {
        // Delete and recreate the test key.
        Registry.CurrentUser.DeleteSubKey("RegistryValueOptionsExample", false);
        RegistryKey rk =
            Registry.CurrentUser.CreateSubKey("RegistryValueOptionsExample");

        // Add a value that contains an environment variable.
        rk.SetValue("ExpandValue", "The path is %PATH%", RegistryValueKind.ExpandString);

        // Retrieve the value, first without expanding the environment
        // variable and then expanding it.
        Console.WriteLine("Unexpanded: \"{0}\"",
            rk.GetValue("ExpandValue", "No Value",
            RegistryValueOptions.DoNotExpandEnvironmentNames));
        Console.WriteLine("Expanded: \"{0}\"", rk.GetValue("ExpandValue"));
    } //Main
} //Example

Remarks

Use the DoNotExpandEnvironmentNames flag with the RegistryKey.GetValue(String, Object, RegistryValueOptions) method overload.

Applies to

Toode Versioonid
.NET Core 1.0, Core 1.1, 6, 7, 8, 9, 10
.NET Framework 2.0, 3.0, 3.5, 4.0, 4.5, 4.5.1, 4.5.2, 4.6, 4.6.1, 4.6.2, 4.7, 4.7.1, 4.7.2, 4.8, 4.8.1
.NET Standard 2.0 (package-provided)
Windows Desktop 3.0, 3.1, 5