Handle hoRegistry
Integer iError bOK bRetVal
String sKey sData
Get Create U_cRegistry to hoRegistry
Move ("Software\Microsoft\Windows\CurrentVersion\Explorer\Shell Folders") to sKey
Set pfAccessRights of hoRegistry to KEY_READ
Set phRootKey of horegistry to HKEY_LOCAL_MACHINE
String sCommonAppData
Get OpenKey of hoRegistry sKey to bOk
If (bOK) Begin
If (ValueExists(hoRegistry,"Common AppData")) Begin
Get ReadString of hoRegistry "Common AppData" to sCommonAppData
End
Else Move "" to sCommonAppData
Send CloseKey of hoRegistry
End
Else Begin
Error 255 "Unable to read shell folders registry"
End
Send Destroy to hoRegistry
If (trim(sCommonAppData)<>"") Begin
String sConfigFile
String sMyAppData
Move (szPathAppend(sCommonAppData,"StarZen\TestApp")) to sMyAppData
Move (szPathAppend(sMyAppData,"TestApp.config")) to sConfigFile
If (SZFileExists(sConsejoConfig)) Begin
Integer hoXML
Get Create U_cXMLDOMDocument to hoXML
If (not(hoXML)) Begin
Error 255 ("Unable to create XML document")
Function_Return (False)
End
Set psDocumentName of hoXML to sConfigFile
Set pbAsync of hoXML to False
Set pbValidateOnParse of hoXML to True
Get LoadXMLDocument of hoXML to bOK
If (not(bOk)) Begin
Error 255 ("Unable to load XML document"+trim(sConfigFilefig))
Send Destroy to hoXML
Function_Return (False)
End
// READ XML FILE
Send Destroy to hoXML
End
End
Instead of using the registry it is recommended to store machine specific configuration data in the common appdata folder
first we use the registry to find the common appdata folder and then simply append a name for the company and also a name for the application. Then simply read an xml file in that folder for our configuration data