process demo: removed platform specific code for testing if data is available, it uses fpc 2.2.0 functionality to get the available bytes and now runs also on *nix.
git-svn-id: https://svn.code.sf.net/p/lazarus-ccr/svn@270 8e941d3f-bd1b-0410-a28a-d453659cc2b4
This commit is contained in:
parent
dc2b1b55c0
commit
6ac89bc136
@ -26,11 +26,11 @@
|
|||||||
</RunParams>
|
</RunParams>
|
||||||
<RequiredPackages Count="2">
|
<RequiredPackages Count="2">
|
||||||
<Item1>
|
<Item1>
|
||||||
<PackageName Value="LCL"/>
|
|
||||||
</Item1>
|
|
||||||
<Item2>
|
|
||||||
<PackageName Value="FCL"/>
|
<PackageName Value="FCL"/>
|
||||||
<MinVersion Major="1" Valid="True"/>
|
<MinVersion Major="1" Valid="True"/>
|
||||||
|
</Item1>
|
||||||
|
<Item2>
|
||||||
|
<PackageName Value="LCL"/>
|
||||||
</Item2>
|
</Item2>
|
||||||
</RequiredPackages>
|
</RequiredPackages>
|
||||||
<Units Count="2">
|
<Units Count="2">
|
||||||
|
@ -56,13 +56,6 @@ var
|
|||||||
|
|
||||||
implementation
|
implementation
|
||||||
|
|
||||||
uses
|
|
||||||
{$ifdef win32}
|
|
||||||
windows;
|
|
||||||
{$else}
|
|
||||||
baseunix, unix;
|
|
||||||
{$endif}
|
|
||||||
|
|
||||||
{ TMultipleProcessDemoForm }
|
{ TMultipleProcessDemoForm }
|
||||||
|
|
||||||
procedure TMultipleProcessDemoForm.CloseButtonClick(Sender:TObject);
|
procedure TMultipleProcessDemoForm.CloseButtonClick(Sender:TObject);
|
||||||
@ -102,24 +95,26 @@ var
|
|||||||
procedure DoStuffForProcess(Process: TProcess; StartButton: TButton;
|
procedure DoStuffForProcess(Process: TProcess; StartButton: TButton;
|
||||||
OutputMemo: TMemo);
|
OutputMemo: TMemo);
|
||||||
var
|
var
|
||||||
TotalBytesAvailable: integer;
|
|
||||||
Buffer: string;
|
Buffer: string;
|
||||||
|
BytesAvailable: DWord;
|
||||||
BytesRead:LongInt;
|
BytesRead:LongInt;
|
||||||
begin
|
begin
|
||||||
if not StartButton.Enabled then
|
if not StartButton.Enabled then
|
||||||
StartButton.Enabled := not Process.Running;
|
StartButton.Enabled := not Process.Running;
|
||||||
if Process.Running then begin
|
if Process.Running then
|
||||||
Windows.PeekNamedPipe(Process.Output.Handle, nil, 0, nil,
|
begin
|
||||||
@TotalBytesAvailable, nil);
|
BytesAvailable := Process.Output.NumBytesAvailable;
|
||||||
while TotalBytesAvailable>0 do begin
|
BytesRead := 0;
|
||||||
SetLength(Buffer, TotalBytesAvailable);
|
while BytesAvailable>0 do
|
||||||
BytesRead := Process.OutPut.Read(Buffer[1], TotalBytesAvailable);
|
begin
|
||||||
|
SetLength(Buffer, BytesAvailable);
|
||||||
|
BytesRead := Process.OutPut.Read(Buffer[1], BytesAvailable);
|
||||||
OutputMemo.Text := OutputMemo.Text + copy(Buffer,1, BytesRead);
|
OutputMemo.Text := OutputMemo.Text + copy(Buffer,1, BytesRead);
|
||||||
Windows.PeekNamedPipe(Process.Output.Handle, nil, 0, nil,
|
BytesAvailable := Process.Output.NumBytesAvailable;
|
||||||
@TotalBytesAvailable, nil);
|
|
||||||
NoMoreOutput := false;
|
NoMoreOutput := false;
|
||||||
end;
|
end;
|
||||||
OutputMemo.SelStart := Length(OutputMemo.Text);
|
if BytesRead>0 then
|
||||||
|
OutputMemo.SelStart := Length(OutputMemo.Text);
|
||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
begin
|
begin
|
||||||
|
Loading…
Reference in New Issue
Block a user