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:

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


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.

Published: March 27, 2000

See also
ABA Document Convert
SMMsg suite
Clarion Viewer
Excel Web-stream
ExcelFile Viewer
SMImport suite
ABA Database Convert
Paradox to Text converter
DBExport tools

Contact to webmaster


Borland Software Code Gear Scalabium Delphi tips

Copyright© 1998-2018, Scalabium Software. All rights reserved.

SMExport advertising