英語で読む

次の方法で共有


RegistryValueOptions 列挙型

定義

レジストリ キーから名前/値ペアを取得するときのオプションの動作を指定します。

この列挙体は、メンバー値のビットごとの組み合わせをサポートしています。

C#
[System.Flags]
public enum RegistryValueOptions
継承
RegistryValueOptions
属性

フィールド

名前 説明
DoNotExpandEnvironmentNames 1

ExpandString 型の値が、埋め込まれた環境変数を展開せずに取得されます。

None 0

オプションの動作は指定されていません。

次のコード サンプルでは、テスト キーを作成し、埋め込み環境変数を持つ値を追加し、展開されたフォームと展開されていないフォームの両方で値を取得します。

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

注釈

メソッド オーバーロードで DoNotExpandEnvironmentNames フラグを RegistryKey.GetValue(String, Object, RegistryValueOptions) 使用します。

適用対象

製品 バージョン
.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