[fpc-pascal] TProcess questions

Andrew Haines AndrewD207 at aol.com
Tue Oct 3 13:55:29 CEST 2006


Adrian Maier wrote:
> So, initially the Environment is empty and the program inherits the
> variables.
> When I append the first variable, it will no longer inherit the variables.
> 
> I find the behaviour counterintuitive:  the first "append" causes the
> Environment to
> be initialised.
> 
> I haven't discovered yet how could the programmer preserve the
> inherited environment
> and only "add" some variables ?

This copies all the envvars to a stringlist. You can add your own of
course too.

function GetEnvironmentVars: TStringList;
var
  I: Integer;
  fName: String;
begin
  Result := TStringList.Create;
  for I := 0 to GetEnvironmentVariableCount-1 do begin
    fName := GetEnvironmentString(I);
    Result.Add(fName);
  end;
end;


HTH

Andrew Haines



More information about the fpc-pascal mailing list