+ Patch from Vincent Snijders to fix passing environment vars in win32

This commit is contained in:
michael 2004-02-03 08:12:22 +00:00
parent 0874e96a94
commit 20e4eac32d

View File

@ -438,10 +438,8 @@ begin
Result:=Result or startf_USEFILLATTRIBUTE; Result:=Result or startf_USEFILLATTRIBUTE;
end; end;
{$ifdef unix}
Type Type
{$ifndef unix}
PPChar = ^PChar;
{$endif}
TPCharArray = Array[Word] of pchar; TPCharArray = Array[Word] of pchar;
PPCharArray = ^TPcharArray; PPCharArray = ^TPcharArray;
@ -478,6 +476,24 @@ begin
FreeMem(List); FreeMem(List);
end; end;
{$else}
Function StringsToPChars(List : TStrings): pointer;
var
EnvBlock: string;
I: Integer;
begin
EnvBlock := '';
For I:=0 to List.Count-1 do
EnvBlock := EnvBlock + List[i] + #0;
EnvBlock := EnvBlock + #0;
GetMem(Result, Length(EnvBlock));
CopyMemory(Result, @EnvBlock[1], Length(EnvBlock));
end;
{$endif}
{$ifdef unix} {$ifdef unix}
Procedure CommandToList(S : String; List : TStrings); Procedure CommandToList(S : String; List : TStrings);
@ -670,8 +686,10 @@ Procedure TProcess.Execute;
Var Var
{$ifndef unix} {$ifndef unix}
PName,PDir,PCommandLine : PChar; PName,PDir,PCommandLine : PChar;
{$endif} FEnv: pointer;
{$else}
FEnv : PPChar; FEnv : PPChar;
{$endif}
FCreationFlags : Cardinal; FCreationFlags : Cardinal;
begin begin
@ -691,7 +709,11 @@ begin
PDir:=Pchar(FCurrentDirectory); PDir:=Pchar(FCurrentDirectory);
{$endif} {$endif}
if FEnvironment.Count<>0 then if FEnvironment.Count<>0 then
{$ifdef unix}
FEnv:=StringsToPcharList(FEnvironment) FEnv:=StringsToPcharList(FEnvironment)
{$else}
FEnv:=StringsToPChars(FEnvironment)
{$endif}
else else
FEnv:=Nil; FEnv:=Nil;
FInheritHandles:=True; FInheritHandles:=True;
@ -717,7 +739,11 @@ begin
{$endif} {$endif}
FRunning:=True; FRunning:=True;
If FEnv<>Nil then If FEnv<>Nil then
{$ifdef unix}
FreePCharList(FEnv); FreePCharList(FEnv);
{$else}
FreeMem(FEnv);
{$endif}
if not (csDesigning in ComponentState) and // This would hang the IDE ! if not (csDesigning in ComponentState) and // This would hang the IDE !
(poWaitOnExit in FProcessOptions) and (poWaitOnExit in FProcessOptions) and
not (poRunSuspended in FProcessOptions) then not (poRunSuspended in FProcessOptions) then
@ -919,7 +945,10 @@ end;
end. end.
{ {
$Log$ $Log$
Revision 1.18 2003-10-30 20:34:47 florian Revision 1.19 2004-02-03 08:12:22 michael
+ Patch from Vincent Snijders to fix passing environment vars in win32
Revision 1.18 2003/10/30 20:34:47 florian
* fixed inherited destroy; call of tprocess * fixed inherited destroy; call of tprocess
Revision 1.17 2003/09/20 12:38:29 marco Revision 1.17 2003/09/20 12:38:29 marco