[Lazarus] Environment variable list

Mattias Gaertner nc-gaertnma at netcologne.de
Wed Aug 21 19:24:11 CEST 2013


On Wed, 21 Aug 2013 12:50:01 -0400
Chris Kelling <kellingc at cox.net> wrote:

> This could be a totally stupid question, but I'm trying to do this blind. Is there a way to get a list if environment variables defined at run time?  There is a get and set, but I don't know the name of the variable I need, so I want to get a list. This should work cross platform, I think. 

Getting the list of environment strings, i.e. name=value pairs:

  SysVarCount:=GetEnvironmentVariableCount;
  for i:=0 to SysVarCount-1 do begin
    Variable:=GetEnvironmentStringUTF8(i+1);
    
  end;

Get a specific value:

Value:=GetEnvironmentVariableUTF8(VariableName);

The UTF8 functions are defined in lazutf8, others are in SysUtils.

Mattias




More information about the Lazarus mailing list