Sto cercando di utilizzare le funzione della dll wininet per connettermi tramite ftp a un server solo che non riesco a capire per quale motivo non riesce a scaricarmi un file potete aiutarmi plz?
- Codice: Seleziona tutto
unit Unit1;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, ExtCtrls,shellapi,TlHelp32,jpeg,wininet;
type
TForm1 = class(TForm)
Image1: TImage;
Timer1: TTimer;
procedure Timer1Timer(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
const LOC:string ='O.jpg';
const ser:string ='O.jpg';
var
t:tpicture;
pass:pansichar;
x:boolean;
Form1: TForm1;
P2:pointer;
P:pointer;
P3:POINTER;
implementation
{$R *.dfm}
function strtoword(s:string):word;
var a:word;
err:integer;
begin
val(s,a,err);
strtoword:=a;
end;
procedure TForm1.Timer1Timer(Sender: TObject);
begin
t:=tpicture.Create;
x:=ftpgetfile(p2,pchar(ser),pchar(loc),False,0
,FTP_TRANSFER_TYPE_BINARY,0) ;
if x then
begin
t.LoadFromFile('O.jpg');
form1.image1.Picture:=t;
end
ELSE
begin
SHOWMESSAGE('Download NN RIUSCITO');
end;
end;
end;
initialization
begin
P := InternetOpen('ECU', 0, nil, 0, 0);
P2:=internetconnect(p,pchar("host'),strToWord('21'),pchar('user'),
pchar('pass'),INTERNET_SERVICE_FTP,INTERNET_FLAG_PASSIVE,0);
IF P2 =NIL THEN
SHOWMESSAGE('CONNECT FAILED')
ELSE
SHOWMESSAGE('La connessione ha avuto successo');
END;
end.
P.S ho sostituito al posto del nome del server originale con host ,al posto dello user 'user',e al posto della pass 'pass'