function FtpAccess.DisconnectFTP : boolean;
begin
if Assigned(FTP) then begin
FTP.disconnect;
FreeAndNil(FTP);
end;
if Assigned(SSL) then
FreeAndNil(SSL);
end;
function FtpAccess.ConnectToSFTPServer(User, Passwd, Host, Port: String): boolean;
begin
Result:= False ;
if not Assigned(FTP) then
FTP := TIdFTP.Create(self);
if not Assigned(SSL) then
SSL := TIdSSLIOHandlerSocketOpenSSL.Create(FTP);
with SSL do begin
ReadTimeout := 60000; // attention si c'est en seconde ou milliseconde
SSLOptions.Method := sslvSSLv23;
SSLOptions.Mode := sslmClient;
end;
with FTP do begin
AutoLogin := True;
IOHandler := SSL;
AutoLogin := True;
Passive := True;
UseTLS := utUseExplicitTLS;
AUTHCmd := tAuthSSL;
DataPortProtection:= ftpdpsPrivate;
Username := User;
Password := Passwd;
Host := Host;
Port := StrToIntDef(Port,21); // on utilise StrToIntDef au cas ou
end;
Try
FTP.Connect;
Result:= FTP.Connected;
Except
on E : Exception do Begin
MyDataModule.AddToFtpLog('ERROR Func ConnectToSFTPServer', E.Message);
MyDataModule.Log('ERROR Func ConnectToSFTPServer',E.className+' ' +E.Message);
end;
end;
end;
aprés il se peut que les api FTP/Socket soit differente Indy pour XP et indy pour 98 ... sans parler des differences enorme de systeme.
mais qui utilise encore windows 98 ?