GetEnvironmentString function
System Information routines
Return to Introduction  Previous page  Next page
Unit
acUtils  

Declaration
function GetEnvironmentString(const St: String): String;  

Description
The GetEnvironmentString retrieves the string value of the specified environment variable of the Windows, from the environment block of the calling process. The St parameter identifies the variable.  

Example
{ returns the searching pathes (SET PATH="...") }  
SearchPathes := GetEnvironmentString('PATH');  

Original code
function GetEnvironmentString(const St: String): String;  
var Len: Integer;  
begin  
  Result := '';  
  Len := GetEnvironmentVariable(PChar(St), nil0);  
  if Len = 0 then Exit;  
  SetLength(Result, Len - 1);  
  GetEnvironmentVariable(PChar(St), PChar(Result), Len);  
end;  

See also
SystemPathes property of the acSystemInfo component.