[fpc-pascal] environmentstrings in windows

Vincent Snijders vsnijders at quicknet.nl
Thu Dec 14 16:43:06 CET 2006

Consider the following program:

{$mode objfpc}{$H+}


   i: integer;
   s: string;

   i := GetEnvironmentVariableCount;
   writeln('VariableCount: ',i);
   s := GetEnvironmentString(1);
   writeln('Variable 1: ', s);
   s := GetEnvironmentString(2);
   writeln('Variable 2: ', s);
   s := GetEnvironmentVariable('=D:');
   writeln('Variable 1: ', s);

If I run this from a command prompt on my windows 2000 computer it gives the 
following output:
VariableCount: 43
Variable 1: =D:=D:\lazarus\bugs\7699
Variable 2: =ExitCode=00000000
Variable 1:

The first two envrionment string are special, in the sense that their name start 
with a =.

but if ask for the value of the environment variable '=D:', it returns the empty 

I am wrestling a bit with how to interprete this. Should I consider these variable 
as special and hidden and ignore them?
Or should code parsing environmentstrings be able to handle variables with a '=' on 
the first position?


More information about the fpc-pascal mailing list