RegistryValueOptions Enumeración

Definición

Especifica el comportamiento opcional cuando se recuperan pares de nombre y valor de una clave del Registro.Specifies optional behavior when retrieving name/value pairs from a registry key.

Esta enumeración tiene el atributo FlagsAttribute, que permite una combinación bit a bit de sus valores de miembro.

public enum class RegistryValueOptions
[System.Flags]
public enum RegistryValueOptions
type RegistryValueOptions = 
Public Enum RegistryValueOptions
Herencia
RegistryValueOptions
Atributos

Campos

DoNotExpandEnvironmentNames 1

Se recupera un valor de tipo ExpandString sin expandir sus variables de entorno incrustadas.A value of type ExpandString is retrieved without expanding its embedded environment variables.

None 0

No se especifica ningún comportamiento opcional.No optional behavior is specified.

Ejemplos

En el ejemplo de código siguiente se crea una clave de prueba, se agrega un valor a una variable de entorno incrustada y se recupera el valor en formularios expandidos y sin expandir.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.

#using <Microsoft.VisualBasic.dll>

using namespace System;
using namespace Microsoft::Win32;
using namespace Microsoft::VisualBasic;

int main()
{
    // Delete and recreate the test key.
    Registry::CurrentUser->DeleteSubKey( L"RegistryValueOptionsExample", false );
    RegistryKey ^ rk = 
        Registry::CurrentUser->CreateSubKey( L"RegistryValueOptionsExample" );
   
    // Add a value that contains an environment variable.
    rk->SetValue( L"ExpandValue", L"The path is %PATH%", 
        RegistryValueKind::ExpandString );
   
    // Retrieve the value, first without expanding the environment
    // variable and then expanding it.
    Console::WriteLine( L"Unexpanded: \"{0}\"", 
                        rk->GetValue( L"ExpandValue", 
                        L"No Value", 
                        RegistryValueOptions::DoNotExpandEnvironmentNames ) );
    Console::WriteLine( L"Expanded: \"{0}\"", rk->GetValue( L"ExpandValue" ) );
 
    return 0;
} //Main
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
Imports Microsoft.Win32

Public Class Example
    Public Shared Sub Main()
        ' Delete and recreate the test key.
        Registry.CurrentUser.DeleteSubKey("RegistryValueOptionsExample", False)
        Dim rk As RegistryKey = _
            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"))
    End Sub
End Class

Comentarios

Use la marca DoNotExpandEnvironmentNames con la RegistryKey.GetValue(String, Object, RegistryValueOptions) sobrecarga del método.Use the DoNotExpandEnvironmentNames flag with the RegistryKey.GetValue(String, Object, RegistryValueOptions) method overload.

Se aplica a