Scalabium Software

SMExport/SMImport suites
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.


Published: March 27, 2000

See also
 
ABA Picture Convert
Clarion to Text converter
Excel Web-stream
ExcelFile Viewer
DBLoad
MAPIMail
Viewer for MS Outlook Messages
ABA Document Convert
Viewer for TNEF-files (winmail.dat)
Protected Storage Viewer
 
 


Contact to webmaster

 

Borland Software Code Gear Scalabium Delphi tips

Copyright© 1998-2024, Scalabium Software. All rights reserved.
webmaster@scalabium.com

SMExport/SMImport suites