- - * - WhiteUnicorn - * - -




* #WhiteUnicorn/ StartPage/ Documentation/DelphiFAQ >


Frequently Asked Questions

Reading dos environment variables

Question:

How do I retrieve a DOS environment variable such as the current path?

Answer:

You can make a call to the Windows API function 

GetDOSEnvironment() under Win16 or the 

GetEnvironmentStrings() function under Win32.



Example:



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;




* #WhiteUnicorn/ StartPage/ Documentation/DelphiFAQ >



- - * - Anastasija aka WhiteUnicorn - * - - LJLiveJournal
PFPhotoFile