Interaction.GetAllSettings(String, String) 方法

定義

從 Windows 登錄的應用程式項目中傳回機碼設定及其對應值的清單 (原本是以 SaveSetting 所建立)。 使用 My 功能可以提供比 GetAllSettings 更強大的登錄作業產能和效能。 如需詳細資訊,請參閱Registry

public:
 static cli::array <System::String ^, 2> ^ GetAllSettings(System::String ^ AppName, System::String ^ Section);
[System.Runtime.Versioning.SupportedOSPlatform("windows")]
public static string[,]? GetAllSettings (string AppName, string Section);
public static string[,] GetAllSettings (string AppName, string Section);
[<System.Runtime.Versioning.SupportedOSPlatform("windows")>]
static member GetAllSettings : string * string -> string[,]
static member GetAllSettings : string * string -> string[,]
Public Function GetAllSettings (AppName As String, Section As String) As String(,)

參數

AppName
String

必要。 String 運算式,包含要求機碼設定的應用程式或專案的名稱。

Section
String

必要。 String 運算式,包含要求機碼設定之區段的名稱。 GetAllSettings 會傳回包含二維字串陣列的物件。 這些字串會包含指定之區段中的所有機碼設定,加上其對應的值。

傳回

String[,]

來自 Windows 登錄之應用程式項目中的機碼設定與其對應值的清單 (原本是以 SaveSetting 所建立)。

使用 My 功能可以提供比 GetAllSettings 更強大的登錄作業產能和效能。 如需詳細資訊,請參閱Registry

屬性

例外狀況

使用者未登入。

範例

此範例會先使用 函 SaveSetting 式,為指定的 AppName應用程式在 Windows 登錄中建立專案,然後使用 GetAllSettings 函式來顯示設定。 請注意,無法使用 擷GetAllSettings取應用程式名稱和Section名稱。 最後,函 DeleteSetting 式會移除應用程式的專案。

' Object to hold 2-dimensional array returned by GetAllSettings.
' Integer to hold counter.
Dim MySettings(,) As String
Dim intSettings As Integer
' Place some settings in the registry.
SaveSetting("MyApp", "Startup", "Top", "75")
SaveSetting("MyApp", "Startup", "Left", "50")
' Retrieve the settings.
MySettings = GetAllSettings("MyApp", "Startup")
For intSettings = LBound(MySettings, 1) To UBound(MySettings, 1)
    WriteLine(1, MySettings(intSettings, 0))
    WriteLine(1, MySettings(intSettings, 1))
Next intSettings
DeleteSetting("MyApp")

備註

GetAllSettings如果 AppNameSection 不存在,則會傳回未初始化Object的 。

因為它會在登錄機碼下 HKEY_LOCAL_USER 運作,除非用戶以互動方式登入, GetAllSettings 所以需要使用者登入。

要從非互動式進程存取的登錄設定, (例如,Mtx.exe) 應該儲存在 或 HKEY_USER\DEFAULT\Software 登錄機碼底下HKEY_LOCAL_MACHINE\Software\

適用於

另請參閱