System Delphi

Title: Getting the DOS environment variables
Question: How do I get the DOS environment variables?
Answer:
To get these variables, you need to use the GetEnvironmentStrings() call. Here's how:
procedure TMainFrm.AddVarsToMemo(Sender: TObject);
var
p : pChar;
begin
Memo1.Lines.Clear;
Memo1.WordWrap := false;
p := GetEnvironmentStrings;
while p^ #0 do begin
Memo1.Lines.Add(StrPas(p));
inc(p, lStrLen(p) + 1);
end;
FreeEnvironmentStrings(p);
end;
GetDOSEnvironment should be used under win16 (and if this is the case, get rid of the FreeEnvironmentStrings as well).
Tested with Windows 98 and delphi 4. Should work fine on other versions of windows and delphi.