{"id":747,"date":"2011-04-19T20:20:44","date_gmt":"2011-04-20T01:20:44","guid":{"rendered":"http:\/\/anvil-of-time.com\/wordpress\/?p=747"},"modified":"2021-03-10T20:09:58","modified_gmt":"2021-03-11T01:09:58","slug":"powerbuilder-application-path","status":"publish","type":"post","link":"https:\/\/anvil-of-time.com\/powerbuilder\/powerbuilder-application-path\/","title":{"rendered":"PowerBuilder &#8211; Application path"},"content":{"rendered":"<p>So you need to check some file you have deployed with your application and you have chosen to put it in the same folder as the executable.  Sure, I&#8217;ll just check the current folder when the application launches and I&#8217;ll have what I need.  Wrong.  Since an application can be launched with a &#8216;Start In&#8217; folder this is not always the correct place.  Instead use the GetModuleFileName API call<\/p>\n<p>First the external function declaration:<\/p>\n<pre name=\"code\" class=\"VB\">FUNCTION int GetModuleFileNameW(&amp;\n           ulong hinstModule, &amp;\n           REF string lpszPath, &amp;\n           ulong cchPath) LIBRARY &quot;kernel32&quot;\n\/\/ or for those of you way back in time\n\nFUNCTION int GetModuleFileNameA(&amp;\n           ulong hinstModule, &amp;\n           REF string lpszPath, &amp;\n           ulong cchPath) LIBRARY &quot;kernel32&quot;<\/pre>\n<p>Now in your script do the following:<\/p>\n<pre name=\"code\" class=\"VB\">string ls_Path\nunsignedlong lul_handle\n\nls_Path = space(1024)\n\nlul_handle = Handle(GetApplication())\nGetModuleFilenameW(lul_handle, ls_Path, 1024)\/\/ or GetModuleFilenameA if appropriate<\/pre>\n<p>You can use the PFC fileservice to easily strip off the exe name from ls_path or do it yourself.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>So you need to check some file you have deployed with your application and you have chosen to put it in the same folder as the executable. Sure, I&#8217;ll just check the current folder when the application launches and I&#8217;ll have what I need. Wrong. Since an application can be launched with a &#8216;Start In&#8217;&hellip;<\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":[],"categories":[3,10],"tags":[12,16,42],"_links":{"self":[{"href":"https:\/\/anvil-of-time.com\/wp-json\/wp\/v2\/posts\/747"}],"collection":[{"href":"https:\/\/anvil-of-time.com\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/anvil-of-time.com\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/anvil-of-time.com\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/anvil-of-time.com\/wp-json\/wp\/v2\/comments?post=747"}],"version-history":[{"count":4,"href":"https:\/\/anvil-of-time.com\/wp-json\/wp\/v2\/posts\/747\/revisions"}],"predecessor-version":[{"id":1942,"href":"https:\/\/anvil-of-time.com\/wp-json\/wp\/v2\/posts\/747\/revisions\/1942"}],"wp:attachment":[{"href":"https:\/\/anvil-of-time.com\/wp-json\/wp\/v2\/media?parent=747"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/anvil-of-time.com\/wp-json\/wp\/v2\/categories?post=747"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/anvil-of-time.com\/wp-json\/wp\/v2\/tags?post=747"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}