Interaction.GetAllSettings(String, String) 方法

定義

回傳一份關鍵設定及其相應值(最初以 SaveSetting 建立),來自應用程式在 Windows 登錄檔中的條目。 使用此My功能能讓你在登錄檔操作中獲得更高的生產力與效能。GetAllSettings 如需詳細資訊,請參閱Registry

public:
 static cli::array <System::String ^, 2> ^ GetAllSettings(System::String ^ AppName, System::String ^ Section);
public static string[,] GetAllSettings(string AppName, string Section);
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[,]

一列關鍵設定及其相應值(最初以 SaveSetting 建立),來自應用程式在 Windows 登錄檔的條目。

使用此My功能能讓你在登錄檔操作中獲得更高的生產力與效能。GetAllSettings 如需詳細資訊,請參閱Registry

例外狀況

使用者未登入。

範例

此範例首先使用 SaveSetting 函式,在應用程式的Windows登錄檔中指定為 AppName,接著使用 GetAllSettings 函式顯示設定。 請注意,應用程式名稱和 Section 名稱無法用 GetAllSettings來取得。 最後,函 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")

備註

GetAllSettingsAppNameSection 或 不存在,則回傳未初始化Object的 。

因為它是在 HKEY_LOCAL_USER 登錄檔金鑰下運作,登錄檔在使用者互動式登入前才會啟用,因此 GetAllSettings 必須使用者先登入。

要從非互動式程序(如 Mtx.exe)存取的登錄檔設定,應儲存在登錄檔金鑰或 HKEY_LOCAL_MACHINE\Software\ 登錄 HKEY_USER\DEFAULT\Software 檔金鑰下。

適用於

另請參閱