Scalabium Software |
|
| Knowledge for your independence'. | |
#71: How can I read the environment string? |
|
If you need read the environemnt strings, you must call the 2
API functions: 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.
|
|
|
Copyright© 1998-2025, Scalabium
Software. All rights reserved. |