unit Unit1;
interface
uses
Winapi.Windows,
Winapi.Messages, System.SysUtils, System.Variants, System.Classes,
Vcl.Graphics,
Vcl.Controls,
Vcl.Forms,
Vcl.Dialogs,
Vcl.StdCtrls,
Vcl.ExtCtrls,
Vcl.ImgList, System.Win.ScktComp,
Vcl.Buttons, JvExButtons, JvButtons,
Vcl.ComCtrls, JvBackgrounds,
Vcl.Imaging.pngimage,
Vcl.Imaging.jpeg, IdBaseComponent, IdComponent, IdTCPConnection, IdTCPClient, IdExplicitTLSClientServerBase, IdFTP;
type
TForm1 =
class(TForm)
BitBtn1: TBitBtn;
Edit1: TEdit;
client: TIdTCPClient;
BitBtn2: TBitBtn;
BitBtn3: TBitBtn;
BitBtn4: TBitBtn;
BitBtn5: TBitBtn;
BitBtn6: TBitBtn;
procedure BitBtn1Click(Sender: TObject);
procedure BitBtn2Click(Sender: TObject);
procedure BitBtn3Click(Sender: TObject);
procedure FormClose(Sender: TObject;
var Action: TCloseAction);
procedure FormDestroy(Sender: TObject);
procedure BitBtn4Click(Sender: TObject);
procedure BitBtn5Click(Sender: TObject);
procedure BitBtn6Click(Sender: TObject);
private
{ Private-Deklarationen }
public
{ Public-Deklarationen }
end;
type
ULThread =
class(TThread)
procedure Execute;
override;
end;
type
DLThread =
class(TThread)
procedure Execute;
override;
end;
type
TCPREAD =
class(TThread)
procedure Execute;
override;
end;
var
Form1: TForm1;
UL : ULThread;
ULFilePath:
String;
ULFileName:
String;
DL : DLThread;
DLFilePath:
String;
DLFileName:
String;
SR : TCPREAD;
implementation
Uses FileStreamUnit;
{$R *.dfm}
procedure TCPREAD.execute;
begin
while not Terminated
do
begin;
form1.Caption := form1.Client.IOHandler.ReadLn;
if terminated
then
begin
break;
end;
end;
end;
procedure ULThread.execute;
var
AStream: TFileStream;
begin
AStream := TFileStream.Create(form1.edit1.text, fmOpenRead + fmShareDenyNone);
// form1.edit1.Text := inttostr(astream.Size);
try
form1.Client.IOHandler.LargeStream := True;
form1.Client.IOHandler.SendBufferSize := 32768;
form1.Client.IOHandler.WriteLn('
FILE');
// send command "FILE"
form1.Client.IOHandler.WriteLn(ExtractFilename(form1.edit1.text));
// send file name
form1.client.IOHandler.WriteLn(IntToStr(AStream.Size));
// send file size
form1.Client.IOHandler.
Write(AStream);
finally
FreeAndNil(AStream);
end;
end;
procedure DLThread.execute;
var
ftpDownStream: TFileStreamEx;
begin
end;
procedure TForm1.BitBtn1Click(Sender: TObject);
begin
client.Connect;
end;
procedure TForm1.BitBtn2Click(Sender: TObject);
begin
client.disconnect;
end;
procedure TForm1.BitBtn3Click(Sender: TObject);
begin
UL := ULThread.Create(True);
UL.FreeOnTerminate := false;
UL.resume
end;
procedure TForm1.BitBtn4Click(Sender: TObject);
begin
form1.Client.IOHandler.WriteLn('
QUIT');
// sende irgend was damit ich was zurück erhalte
end;
procedure TForm1.FormCreate(Sender: TObject);
begin
SR := TCPREAD.Create(true);
SR.FreeOnTerminate := true;
SR.start;
end;
procedure TForm1.FormClose(Sender: TObject;
var Action: TCloseAction);
begin
if Client.Connected
then
Client.Disconnect;
end;
procedure TForm1.FormDestroy(Sender: TObject);
begin
if Client.Connected
then
Client.Disconnect;
end;
end.