Read and write DOS environment variables  

Send By: Q3 Team
Web : www.q3.nu
Email: dlib@q3.nu
Date: 07/01/00

Tip accessed 506 times

 


Using GetEnvironmentVariable.

Example:

  • Crea un form (Form1) con un TButton (Button1) y un TLabel (Label1)
  • Put this code into OnClick event of Button1:


     	procedure TForm1.Button1Click(Sender: TObject);
     	var
     	   buffer:pchar;
     	begin
     	  GetMem(buffer,200);  {Reservamos sitio para la respuesta}
     	  GetEnvironmentVariable(PChar('PATH'),buffer,200);
     	  Label1.Caption:=StrPas(buffer);
     	  FreeMem(buffer,200);
     	end;
    



    And Label1 will show the value of the PATH environment variable