[Lazarus] How to add & change application EnvironmentList ?
Michael Van Canneyt
michael at freepascal.org
Wed Aug 26 23:44:34 CEST 2015
On Wed, 26 Aug 2015, FreeMan wrote:
> On 26.08.2015 22:22, Michael Van Canneyt wrote:
>> I understand this. That is exactly what AProcess.Environment does.
>>
>> Michael.
>
> AProcess.Environment.Add('LD_LIBRARY_PATH=' + fb_RootPath);
> AProcess.Environment.Add('FIREBIRD=' + fb_RootPath);
> for I := 0 to GetEnvironmentVariableCount do begin
> AProcess.Environment.Add(GetEnvironmentString(I));
> Form1.Memo1.Lines.Add(AProcess.Environment.Strings[I]);
> end;
>
> Form1.Memo1.Lines.Add('');
> Form1.Memo1.Lines.Add('-------------------------------');
> Form1.Memo1.Lines.Add('--------------------');
> Form1.Memo1.Lines.Add('');
> Application.GetEnvironmentList(Form1.Memo1.Lines);
>
> this is result:
> 1-) AProcess.Environment result
> LD_LIBRARY_PATH=/opt/proje_laz/projeler/shared/firebird/Embeded/test/fb_embed_linux64/
> FIREBIRD=/opt/proje_laz/projeler/shared/firebird/Embeded/test/fb_embed_linux64/
> KDE_FULL_SESSION=true
> KDE_FULL_SESSION=true
> GNOME_KEYRING_PID=1900
> GS_LIB=/home/freeman/.fonts
>
> ................................
> ................................
>
> 2-)Application.GetEnvironmentList result
> KDE_FULL_SESSION=true
> GNOME_KEYRING_PID=1900
> GS_LIB=/home/freeman/.fonts
>
>
> var AProcess: TProcess;
> AProcess := TProcess.Create(Application);
>
> AProcess is different class, is that synchronous with main application's
> EnvironmentList ?
For the newly started process, yes.
Not for the CURRENT process.
> My test is say no. It's not work in same session. For test
> I made bash sript, I wrote in export bla bla then execute it with tprocess,
> but not added to application's EnvironmentList.
In the calling program: Of course not. only in the called program.
I use this technique to provide environment parameters to a newly started program since many years.
Michael.
More information about the Lazarus
mailing list