1 2 unit Unit1; 3 4 interface 5 6 uses 7 Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms, 8 Dialogs, StdCtrls; 9 10 type 11 TForm1 = class(TForm) 12 Memo1: TMemo; 13 Button1: TButton; 14 procedure Button1Click(Sender: TObject); 15 private 16 { Private declarations } 17 public 18 19 { Public declarations } 20 end; 21 22 var 23 Form1: TForm1; 24 25 implementation 26 27 {$R *.dfm} 28 29 procedure GetEnvironmentVar(EnvironmentStrings: TStrings); 30 var 31 PEnv, 32 PCopyEnv: PChar; 33 begin { GetEnvironmentStringsList } 34 EnvironmentStrings.Clear; 35 PEnv := GetEnvironmentStrings; 36 PCopyEnv := PEnv; 37 if PCopyEnv<>nil then 38 repeat 39 EnvironmentStrings.Add(StrPas(PCopyEnv)); 40 Inc(PCopyEnv, StrLen(PCopyEnv) + 1); 41 until PCopyEnv^=#0; 42 FreeEnvironmentStrings(PEnv); 43 PCopyEnv := nil 44 end; 45 46 procedure TForm1.Button1Click(Sender: TObject); 47 begin 48 GetEnvironmentVar(memo1.lines); 49 end; 50 51 end. 52