delphi获取系统环境变量

procedure TForm1.Button1Click(Sender: TObject);var p : pChar;begin Memo1.Lines.Clear; Memo1.WordWrap := false; {$IFDEF WIN32} p := GetEnvironmentStrings; {$

procedure TForm1.Button1Click(Sender: TObject);
var
  p : pChar;
begin
  Memo1.Lines.Clear;
  Memo1.WordWrap := false;
 {$IFDEF WIN32}
  p := GetEnvironmentStrings;
 {$ELSE}
  p := GetDOSEnvironment;
 {$ENDIF}
  while p^ <> #0 do begin
    Memo1.Lines.Add(StrPas(p));
    inc(p, lStrLen(p) + 1);
  end;
 {$IFDEF WIN32}
  FreeEnvironmentStrings(p);
 {$ENDIF}
end;

相关推荐

[!--temp.pl--]