RegistryValueOptions 列舉
定義
重要
部分資訊涉及發行前產品,在發行之前可能會有大幅修改。 Microsoft 對此處提供的資訊,不做任何明確或隱含的瑕疵擔保。
在擷取登錄機碼的名稱/值組時,指定選擇項行為。
此列舉支援其成員值的位元組合。
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) 。