[fpc-pascal] InstantFPC and argv
XHajT03 at hajny.biz
Sat May 5 14:02:12 CEST 2012
On Sat, May 5, 2012 09:22, Michael Van Canneyt wrote:
> On Fri, 4 May 2012, Mattias Gaertner wrote:
>> On Fri, 04 May 2012 17:22:16 +0200
>> dhkblaszyk at zeelandnet.nl wrote:
>>> I'm creating a script to be executed by instantfpc when I noticed
>>> that paramstr(0) does not reflect the location of the script but the
>>> location of the cached executable. Is there a way to alter this
>>> programatically to the script location? Is there an alternative way?
>> instantfpc passes as first parameter the original file name.
>> But execv overrides the first argument with the executed file. AFAIK
>> there is no alternative.
>> You can set an environment variable.
> I think the environment variable is the best and easiest shot.
My proposal is platform independent (i.e. it will work also under Win32,
OS/2, etc., without any changes). Your proposal probably requires starting
the compiled binary using platform specific API functions to run it with a
modified environment rather than using ExecuteProcess which results in
passing the standard parent's environment (changing the current's process
environment may not be supported on all platforms).
More information about the fpc-pascal