Leggere in inglese

Condividi tramite


RegistryValueOptions Enumerazione

Definizione

Specifica un comportamento facoltativo per il recupero delle coppie nome/valore da una chiave del Registro di sistema.

Questa enumerazione supporta una combinazione bit per bit dei rispettivi valori dei membri.

C#
[System.Flags]
public enum RegistryValueOptions
Ereditarietà
RegistryValueOptions
Attributi

Campi

Nome Valore Descrizione
DoNotExpandEnvironmentNames 1

Viene recuperato un valore di tipo ExpandString senza espandere le relative variabili di ambiente incorporate.

None 0

Non viene specificato alcun comportamento facoltativo.

Esempio

L'esempio di codice seguente crea una chiave di test, aggiunge un valore con una variabile di ambiente incorporata e recupera il valore in moduli espansi e non estesi.

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

Commenti

Usare il flag DoNotExpandEnvironmentNames con l'overload del RegistryKey.GetValue(String, Object, RegistryValueOptions) metodo.

Si applica a

Prodotto Versioni
.NET Core 1.0, Core 1.1, 6, 7, 8, 9
.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
Windows Desktop 3.0, 3.1, 5