I read in the help that you can set an enviroment block with createprocess,
and my question is how? A code example would be nice.
Regards
Torbjörn Johansson
> I read in the help that you can set an enviroment block with createprocess,
> and my question is how? A code example would be nice.
CreateProcess has a parameter called lpEnvironment. If you provide nil
there, the created process inherits the parent's environment. To run the
child process with another environment, provide a PChar pointing to
something like
'PATH=C:\Bla;C:\Blo'#0'TEMP=C:\winnt\temp'#0#0
To create such a pointer from a TStrings,use something like
function ZeroSeparatedList(L: TStrings): PChar;
begin
Result := PChar(StringReplace(L.Text, #13#10, #0, [rfReplaceAll]));
end;
Note that the child process creates a copy of the provided environment,
so it's fine to use simply
CreateProcess(..., ZeroSeparatedList(ChildEnv), ...
without any need to alloc or free additional buffers.
-Michael
In addition you can also use the CreateEnvironmentBlock API to get the
environment for a specific user...
best regards,
Marcel van Brakel
Project JEDI: http://delphi-jedi.org
Do not send me private e-mail unless explicitly requested otherwise.
If you do anyway please include a billing address...
Torbjörn J
"Michael Winter" <delph...@gmx.net> wrote in message
news:3b31066b_1@dnews...
Torbjörn J
"Marcel van Brakel" <brakelm...@chello.nl> wrote in message
news:MPG.159b24923...@newsgroups.borland.com...
> In addition you can also use the CreateEnvironmentBlock API to get the
> environment for a specific user...
It's not in the API OH, and I'm too lazy to open MSDN. Is it a W2K
specific call? However, thank you for the hint.
-Michael
NT 4 up. You can find a declaration in the WinUser.pas file from my
win32api library at http://delphi-jedi.org