Scalabium Software

SMExport advertising

Knowledge for your independence.
Home Delphi and C++Builder tips



#71:How can I read the environment string?

If you need read the environemnt strings, you must call the 2 API functions:
GetEnvironemtnStrings and FreeEnvironmentStrings:

var
  Env1, Env2: PChar;
  lstStrings: TStrings;
begin
  lstStrings := TStringList.Create;
  Env1 := GetEnvironmentStrings;
  Env2 := PEnv1;
  if Env2 <> nil then
    repeat
      lstStrings.Add(StrPas(Env2));
      inc(Env2, StrLen(Env2) + 1);
    until Env2^ = #0;
  FreeEnvironmentStrings(Env1);
  Env2 := nil;

  <...>
  lstStrings.Free
end;

The GetEnvironmentStrings function returns the address of the environment block for the current process. Each environment variable is null terminated. The set of strings is double null terminated.

As alternative method, you can read a specified variable. The GetEnvironmentVariable function retrieves the value of the specified variable from the environment block of the calling process. The value is in the form of a null-terminated string of characters.

See also
 
SMExport suite
SMImport suite
SMReport
SMDBGrid
MAPIMail
Paradox Viewer
Paradox ActiveX
ExcelFile Viewer
Metafile Convert
DBLoad
DBExport tools
 
 
Contact to webmaster

 

Borland Software Code Gear Scalabium Delphi tips

Copyrightc 1998-2008, Scalabium Software. All rights reserved.
webmaster@scalabium.com

March 27, 2000

SMExport advertising