Add Plinkremote unit as a preparation for a better integration of plink.exe into our SSH tunnel.

See
* http://www.delphipraxis.net/70989-komponente-fuer-ssh-verbindung-6.html
* http://www.heidisql.com/forum.php?t=15206
* issue #2902
This commit is contained in:
Ansgar Becker
2014-03-25 09:43:51 +00:00
parent 5e876bca62
commit 51b531dbe3
3 changed files with 602 additions and 1 deletions

63
source/UPipeThread.pas Normal file
View File

@ -0,0 +1,63 @@
unit UPipeThread;
interface
uses
Windows, Classes;
type
TPipeThread = class(TThread)
private
FReadPipeData: TThreadMethod;
FProcessHandle: THandle;
FWillSuspend : Boolean;
protected
procedure Execute; override;
public
procedure Resume; reintroduce;
property ProcessHandle : THandle
read FProcessHandle write FProcessHandle;
property ReadPipeData: TThreadMethod
read FReadPipeData write FReadPipeData;
property WillSuspend : Boolean
read FWillSuspend write FWillSuspend;
end;
implementation
{ Wichtig: Methoden und Eigenschaften von Objekten in visuellen Komponenten d<>rfen
nur in einer Methode namens Synchronize aufgerufen werden, z.B.
Synchronize(UpdateCaption);
und UpdateCaption k<>nnte folgenderma<6D>en aussehen:
procedure TPipeThread.UpdateCaption;
begin
Form1.Caption := 'Aktualisiert in einem Thread';
end; }
{ TPipeThread }
procedure TPipeThread.Execute;
begin
FWillSuspend := false;
while (WaitForSingleObject(ProcessHandle,1) <> WAIT_OBJECT_0)
and not Terminated do
begin
if Assigned(FReadPipeData) then
Synchronize(FReadPipeData);
if FWillSuspend then
Suspend
else
Sleep(1);
end;
end;
procedure TPipeThread.Resume;
begin
FWillSuspend := false;
inherited;
end;
end.