RegistryValueOptions Перечисление
Важно!
Некоторые сведения относятся к предварительной версии продукта, в которую до выпуска могут быть внесены существенные изменения. Майкрософт не предоставляет никаких гарантий, явных или подразумеваемых, относительно приведенных здесь сведений.
Определяет необязательное поведение при возвращении пар "имя-значение" из раздела реестра.
Это перечисление поддерживает побитовую комбинацию значений его членов.
public enum class RegistryValueOptions
[System.Flags]
public enum RegistryValueOptions
[<System.Flags>]
type RegistryValueOptions =
Public Enum RegistryValueOptions
- Наследование
- Атрибуты
Имя | Значение | Описание |
---|---|---|
DoNotExpandEnvironmentNames | 1 | Значение типа ExpandString возвращается без расширения соответствующих встроенных переменных среды. |
None | 0 | Необязательное поведение не задано. |
В следующем примере кода создается тестовый ключ, добавляется значение с внедренной переменной среды и извлекается значение как в развернутой, так и в неразвернутой форме.
#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
Используйте флаг 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 |
Отзыв о .NET
.NET — это проект с открытым исходным кодом. Выберите ссылку, чтобы оставить отзыв: