RegRead 方法會從 xml 讀取特性詳細資料,然後根據提供的類型傳回特性的值。
範例:
如果是 dbConnection 類型,它會根據使用者指定的特性名稱,傳回資料庫連線字串以及資料庫提供者。
語法
WshellObj.RegRead(propertyName)
引數:
propertyName – 等同於使用者在 xml 中所指定、類型為 dbConnection 的 property 元素名稱屬性。
必須遵循下列步驟才能使用 RegRead 方法:
建立包含特性詳細資料的 xml 檔案。請參閱下方螢幕擷取畫面以瞭解 xml 檔案的格式。

將參數名稱為 FMRegPropertyFilePath 的新項目插入表格 XFM_PARAMETERS 和 XFM_PARAMETERS_DEFAULT,其值應指向上一步中建立的 xml 檔案路徑。
以下是可在資料庫中執行的查詢範例,用來分別在兩個表格中新增必要參數。
Insert into XFM_PARAMETERS (ParameterName,ClusterName,ServerName,ApplicationName, CategoryName,Value) Values ('FMRegPropertyFilePath’, 'ALL','ALL','ALL','ALL', 'C:\sample.xml')
Insert into XFM_PARAMETERS_DEFAULTS (name,Type,Hidden,Validation, Description,DefaultValue) Values ('FMRegPropertyFilePath’, 1,1,'',' XML File path for FM Registry Property for DB Connection ', 'C:\sample.xml')
在指令碼檔案中,於 RegRead 方法中輸入等同於使用者在 xml 檔案中所建立、類型為 dbConnection 的 property 元素名稱屬性的 propertyName。
範例:
Public Const strKey = "HFMCustomConnection1"
Set objShell = CreateObject("WScript.Shell")
strDBConnection = objShell.RegRead(strKey)
Output: - strDBConnection will contain string in the below format
Provider=providerType;DRIVER=driverDetails
Note:
若要反映在 xml 中所做的新變更,使用者必須關閉並重新開啟應用程式,因為在開啟應用程式時會快取 xml 詳細資料,並在之後使用。