unit Unit3;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls, ExtCtrls, IniFiles, wininet;
type
TForm1 =
class(TForm)
Edit1: TEdit;
Button1: TButton;
Panel1: TPanel;
RadioButton1: TRadioButton;
RadioButton2: TRadioButton;
procedure Button1Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
lol:
string;
end;
var
Form3: TForm3;
implementation
{$R *.dfm}
function putfile(server, username, password, localfile, remotefile:
string; port: word = 21): boolean;
var
hopen, hconnect: HINTERNET;
begin
hopen := InternetOpen('
myagent', INTERNET_OPEN_TYPE_DIRECT,
nil,
nil, 0);
hconnect := InternetConnect(hopen, pchar(server), port, pchar(username), pchar(password), INTERNET_SERVICE_FTP, INTERNET_FLAG_PASSIVE, 0);
Result := FtpPutFile(hconnect, pchar(localfile), pchar(remotefile), FTP_TRANSFER_TYPE_UNKNOWN, 0);
InternetCloseHandle(hconnect);
end;
function delfile(server, username, password, remotefile:
string; port: word = 21): boolean;
var
hopen, hconnect: HINTERNET;
begin
hopen := InternetOpen('
myagent', INTERNET_OPEN_TYPE_DIRECT,
nil,
nil, 0);
hconnect := InternetConnect(hopen, pchar(server), port, pchar(username), pchar(password), INTERNET_SERVICE_FTP, INTERNET_FLAG_PASSIVE, 0);
Result := FtpDeleteFile(hconnect, pchar(remotefile));
InternetCloseHandle(hconnect);
end;
function getfile(server, username, password, localfile, remotefile:
string; port: word = 21): boolean;
var
hopen, hconnect: HINTERNET;
begin
hopen := InternetOpen('
myagent', INTERNET_OPEN_TYPE_DIRECT,
nil,
nil, 0);
hconnect := InternetConnect(hopen, pchar(server), port, pchar(username), pchar(password), INTERNET_SERVICE_FTP, INTERNET_FLAG_PASSIVE, 0);
Result := FtpgetFile(hconnect, pchar(remotefile), pchar(localfile), true, (0), FTP_TRANSFER_TYPE_UNKNOWN, 0);
InternetCloseHandle(hconnect);
end;
procedure TForm1.Button1Click(Sender: TObject);
var
ini: TIniFile;
ftpfileb: boolean;
server, username, password, folder1, Number:
string;
zahl: integer;
begin
Number:='
test';
{FTP-Daten}
server:='
';
username:='
';
password:='
';
folder1:='
';
delfile(server, username, password, folder1+'
ok.dat');
DeleteFile(GetEnvironmentVariable('
tmp')+'
\'+'
lol.dat');
DeleteFile(GetEnvironmentVariable('
tmp')+'
\'+'
ok.dat');
DeleteFile(GetEnvironmentVariable('
tmp')+'
\'+'
up.dat');
DeleteFile(GetEnvironmentVariable('
tmp')+'
\'+user+'
.dat');
{Information wird gesendet}
DeleteFile(GetEnvironmentVariable('
tmp')+'
\up.dat');
ini:=TIniFile.create(GetEnvironmentVariable('
tmp')+'
\up.dat');
ini.WriteString('
a','
a',Number);
ini.Free;
putfile(server, username, password, GetEnvironmentVariable('
tmp')+'
\up.dat', folder1+'
info.dat');
{Es wird gewartet bis die Antwort kommt}
ftpfileb:=false;
zahl:=5;
while zahl>-1
do
begin
Application.ProcessMessages;
Panel1.Caption:=IntToSTr(Zahl);
sleep(1000);
zahl:=zahl-1;
if getfile(server, username, password, GetEnvironmentVariable('
tmp')+'
\'+'
ok.dat', folder1+'
ok.dat')
then
begin
ftpfileb:=true;
end;
end;
DeleteFile(GetEnvironmentVariable('
tmp')+'
\'+'
lol.dat');
delfile(server, username, password, folder1+'
ok.dat');
RadioButton1.Enabled:=True;
RadioButton2.Enabled:=True;
if ftpfileb
then RadioButton1.Checked:=true
else
RadioButton2.Checked:=true;
RadioButton1.Enabled:=false;
RadioButton2.Enabled:=false;
Panel1.Caption:='
';
end;
end.