Sign in with Microsoft
Sign in or create an account.
Hello,
Select a different account.
You have multiple accounts
Choose the account you want to sign in with.

附註: 如果 Microsoft Jet Expression Service 在沙箱模式中執行,會停用本主題中所述的函數、方法、物件或屬性,以免評估可能不安全的表達式。 如需沙盒模式的詳細資訊,請在 [說明] 中搜尋「沙盒模式」。

傳回 Macintosh 上 Windows 登錄或 (中應用程式專案的關鍵設定值,) 應用程式初始化檔案中的資訊。

語法

GetSetting ( appname , section, key [, default ] )

GetSettin g 函數語法具有下列自變數:

引數

描述

appname

必要。 字串運算式 包含要求按鍵設定之應用程式或項目的名稱。 在 Macintosh 上,這是 [系統] 資料夾中 [喜好設定] 資料夾中初始化檔案的檔名。

章節

必要。 包含找到按鍵設定之區段名稱的字串表示式。

按鍵

必要。 包含要傳回之按鍵設定名稱的字串表示式。

預設

選擇性。 若未在索引鍵設定中設定任何值,則包含要傳回之值的表達式。 如果省略, 會假設 default 為零長度字串 (“”) 。


註解

如果 GetSetting 自變數中命名的任何專案不存在, GetSetting 會 傳回 預設值。

範例

附註: 下列範例示範如何在 Visual Basic for Applications (VBA) 模組中使用此函數。 如需使用 VBA 的詳細資訊,請在 [搜尋] 旁的下拉式清單中選取 [開發人員參考],並在 [搜尋] 方塊中輸入一個或多個字詞。

此範例首先使用 SaveSetting 語句,讓 16 位 Windows 平臺上的 Windows 登錄 (或 .ini 檔案專案) 指定為 appname 的應用程式,然後使用 GetSetting 函數顯示其中一個設定。 由於已指定 預設 自變數,因此保證會傳回某些值。 請注意,無法使用 GetSetting 擷取名稱。 最後, DeleteSetting 語 句會移除應用程式的所有專案。

' Variant to hold 2-dimensional array returned 
' by GetSetting.
Dim MySettings As Variant
' Place some settings in the registry.
SaveSetting "MyApp","Startup", "Top", 75
SaveSetting "MyApp","Startup", "Left", 50
Debug.Print GetSetting(appname := "MyApp", _
section := "Startup", _
key := "Left", default := "25")
DeleteSetting "MyApp", "Startup"

Need more help?

Want more options?

探索訂閱權益、瀏覽訓練課程、瞭解如何保護您的裝置等等。

社群可協助您詢問並回答問題、提供意見反應,以及聆聽來自具有豐富知識的專家意見。

Was this information helpful?

How satisfied are you with the translation quality?
What affected your experience?
By pressing submit, your feedback will be used to improve Microsoft products and services. Your IT admin will be able to collect this data. Privacy Statement.

Thank you for your feedback!

×