{"id":85,"date":"2014-07-21T11:06:04","date_gmt":"2014-07-21T15:06:04","guid":{"rendered":"http:\/\/salzlechner.com\/dev\/?p=85"},"modified":"2016-03-11T07:15:22","modified_gmt":"2016-03-11T12:15:22","slug":"storing-configuration-information-in-common-appdata-folder","status":"publish","type":"post","link":"http:\/\/salzlechner.com\/dev\/2014\/07\/21\/storing-configuration-information-in-common-appdata-folder\/","title":{"rendered":"Storing configuration information in common appdata folder"},"content":{"rendered":"<pre class=\"lang:default decode:true  \">Handle hoRegistry\r\nInteger iError bOK bRetVal\r\nString sKey sData\r\n    \r\nGet Create U_cRegistry to hoRegistry\r\nMove (\"Software\\Microsoft\\Windows\\CurrentVersion\\Explorer\\Shell Folders\") to sKey\r\nSet pfAccessRights of hoRegistry to KEY_READ\r\nSet phRootKey of horegistry to HKEY_LOCAL_MACHINE\r\n            \r\nString sCommonAppData\r\nGet OpenKey of hoRegistry sKey to bOk\r\nIf (bOK) Begin\r\n    If (ValueExists(hoRegistry,\"Common AppData\")) Begin\r\n        Get ReadString of hoRegistry \"Common AppData\" to sCommonAppData\r\n    End\r\n    Else Move \"\" to sCommonAppData\r\n\r\n    Send CloseKey of hoRegistry\r\nEnd\r\nElse Begin\r\n    Error 255 \"Unable to read shell folders registry\"\r\nEnd\r\n\r\nSend Destroy to hoRegistry\r\n    \r\nIf (trim(sCommonAppData)&lt;&gt;\"\") Begin\r\n    String sConfigFile\r\n    String sMyAppData\r\n    \r\n    Move (szPathAppend(sCommonAppData,\"StarZen\\TestApp\")) to sMyAppData\r\n    Move (szPathAppend(sMyAppData,\"TestApp.config\")) to sConfigFile\r\n    \r\n    If (SZFileExists(sConsejoConfig)) Begin\r\n        Integer hoXML \r\n        Get Create U_cXMLDOMDocument to hoXML\r\n        If (not(hoXML)) Begin\r\n            Error 255 (\"Unable to create XML document\")\r\n            Function_Return (False)\r\n        End\r\n    \r\n        Set psDocumentName of hoXML to sConfigFile\r\n        Set pbAsync of hoXML to False\r\n        Set pbValidateOnParse of hoXML to True\r\n    \r\n        Get LoadXMLDocument of hoXML to bOK\r\n        If (not(bOk)) Begin\r\n            Error 255 (\"Unable to load XML document\"+trim(sConfigFilefig))\r\n            Send Destroy to hoXML\r\n            Function_Return (False)\r\n        End\r\n\r\n        \/\/ READ XML FILE\r\n\r\n        Send Destroy to hoXML\r\n    End\r\nEnd<\/pre>\n<p>&nbsp;<\/p>\n<p>Instead of using the registry it is recommended to store machine specific configuration data in the common appdata folder<\/p>\n<p>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<\/p>\n<p>&nbsp;<\/p>\n","protected":false},"excerpt":{"rendered":"<p>this post shows how to properly store application data in a configuration file in the common appdata folder<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_et_pb_use_builder":"","_et_pb_old_content":"","_et_gb_content_width":"","ngg_post_thumbnail":0,"footnotes":""},"categories":[6,4],"tags":[],"class_list":["post-85","post","type-post","status-publish","format-standard","hentry","category-dataflex","category-windows"],"_links":{"self":[{"href":"http:\/\/salzlechner.com\/dev\/wp-json\/wp\/v2\/posts\/85","targetHints":{"allow":["GET"]}}],"collection":[{"href":"http:\/\/salzlechner.com\/dev\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/salzlechner.com\/dev\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/salzlechner.com\/dev\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"http:\/\/salzlechner.com\/dev\/wp-json\/wp\/v2\/comments?post=85"}],"version-history":[{"count":3,"href":"http:\/\/salzlechner.com\/dev\/wp-json\/wp\/v2\/posts\/85\/revisions"}],"predecessor-version":[{"id":291,"href":"http:\/\/salzlechner.com\/dev\/wp-json\/wp\/v2\/posts\/85\/revisions\/291"}],"wp:attachment":[{"href":"http:\/\/salzlechner.com\/dev\/wp-json\/wp\/v2\/media?parent=85"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/salzlechner.com\/dev\/wp-json\/wp\/v2\/categories?post=85"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/salzlechner.com\/dev\/wp-json\/wp\/v2\/tags?post=85"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}