[Lazarus] How to add & change application EnvironmentList ?

Michael Van Canneyt michael at freepascal.org
Wed Aug 26 20:22:58 CEST 2015



On Wed, 26 Aug 2015, FreeMan wrote:

> On 26.08.2015 18:35, Michael Van Canneyt wrote:
>> AProcess.Environment must be used for this.
>> 
>> Michael.
> Sorry, I didn't understand what you mean.
> This is my test code, before and after execute, write all environment 
> variables in memo1, but same variables. Tprocess class similar not working.
>
>    if Assigned(AProcess)then FreeAndNil(AProcess);
>    AProcess := TProcess.Create(Application);
>    AProcess.Options := AProcess.Options + [poWaitOnExit, poUsePipes];
>      Form1.Memo1.Clear;
>      for I := 1 to GetEnvironmentVariableCount do begin
>      AProcess.Environment.Add(GetEnvironmentString(I));

Here you must add

      AProcess.Environment.Add('LD_LIBRARY_PATH='+fb_RootPath);

It is not necessary to execute the shell.

I use this technique myself, so I am sure it works.

Michael.




More information about the Lazarus mailing list