Interaction.SaveSetting(String, String, String, String) 方法
定義
重要
部分資訊涉及發行前產品,在發行之前可能會有大幅修改。 Microsoft 對此處提供的資訊,不做任何明確或隱含的瑕疵擔保。
在 Windows 登錄中儲存或建立應用程式項目。 My
功能可以提供比 SaveSetting
更強大的登錄作業產能和效能。 如需詳細資訊,請參閱Registry。
public:
static void SaveSetting(System::String ^ AppName, System::String ^ Section, System::String ^ Key, System::String ^ Setting);
[System.Runtime.Versioning.SupportedOSPlatform("windows")]
public static void SaveSetting (string AppName, string Section, string Key, string Setting);
public static void SaveSetting (string AppName, string Section, string Key, string Setting);
[<System.Runtime.Versioning.SupportedOSPlatform("windows")>]
static member SaveSetting : string * string * string * string -> unit
static member SaveSetting : string * string * string * string -> unit
Public Sub SaveSetting (AppName As String, Section As String, Key As String, Setting As String)
參數
- AppName
- String
必要。 String
運算式,包含此設定所套用的應用程式或專案的名稱。
- Section
- String
必要。 String
運算式,包含機碼設定儲存所在的區段名稱。
- Key
- String
必要。 String
運算式,包含所要儲存之機碼設定的名稱。
- Setting
- String
必要。 運算式,包含 Key
所設定成的值。
- 屬性
例外狀況
無法建立登錄機碼或使用者未登入。
範例
下列範例會先使用 函 SaveSetting
式在應用程式的 Windows 登錄 MyApp
中建立專案,然後使用 函 DeleteSetting
式來移除這些專案。
' Place some settings in the registry.
SaveSetting("MyApp", "Startup", "Top", "75")
SaveSetting("MyApp", "Startup", "Left", "50")
' Remove Startup section and all its settings from registry.
DeleteSetting("MyApp", "Startup")
' Remove MyApp from the registry.
DeleteSetting("MyApp")
備註
函式 SaveSetting
會將索引鍵新增至 HKEY_CURRENT_USER\Software\VB and VBA Program Settings
。
如果因為任何原因而無法儲存密鑰設定,就會發生錯誤。
SaveSetting
要求使用者登入,因為它在登錄機碼下 HKEY_LOCAL_USER
運作,除非使用者以互動方式登入,否則不會作用中。
要從非互動式進程存取的登錄設定, (例如,Mtx.exe) 應該儲存在 或 HKEY_USER\DEFAULT\Software
登錄機碼底下HKEY_LOCAL_MACHINE\Software\
。
SaveSetting
Write
需要 與 Create
RegistryPermission。
適用於
另請參閱
意見反應
https://aka.ms/ContentUserFeedback。
即將登場:在 2024 年,我們將逐步淘汰 GitHub 問題作為內容的意見反應機制,並將它取代為新的意見反應系統。 如需詳細資訊,請參閱:提交並檢視相關的意見反應