Newsgroups : Borland : borland.public.delphi.internet.winsock : 2006 Jul : DLL use with ftp client

www.cryer.info
Managed Newsgroup Archive

DLL use with ftp client

Subject:DLL use with ftp client
Posted by:"Carlo" (c.levis@nospamscpnet.it)
Date:Thu, 6 Jul 2006 10:07:19

Hi
i am testing dll in Delphi 7 enterprise and i want to create an application
that use dll for establish ftp connection (i use indy client component).

Source code of application is this:

procedure T_Main.SpeedButton1Click(Sender: TObject);
begin
  Try
    IdFTP1:=_FtpConnect(Edit28.Text,Edit29.Text,Edit30.Text);  // I want to
call dll function for establish ftp connection; dll function returns a
TidFtp connected...
    if IdFTP1.Connected then
       Label1.Caption:='CONNECTED'
    else
       Label1.Caption:='DISCONNECTED'
  Except
  End;
End;

Source code of my dll is this:

function _FtpConnect(_Host: String; _User: String; _Password: String):
TIdFtp; stdcall;
var
  _TIdFTP: TIdFtp;
begin
  try
    _TIdFTP:=TIdFtp.Create(nil);
    _TIdFTP.Host:=_Host;
    _TIdFTP.Username:=_User;
    _TIdFTP.Password:=_Password;
    if _TIdFTP.Connected=False then
       _TIdFTP.Connect;
    Result:=_TIdFTP;
  except
  end;
end;

...When i click speedbutton1 of my application,  connection is ok and
Label1.Caption is = 'CONNECTED'.

But now i have my problem: i need to copy a file from client to ftp and i
use this code on my application:

procedure T_Main.SpeedButton2Click(Sender: TObject);
begin
  if IdFTP1.Connected=False then
     begin
       ShowMessage('Ftp non connected...');
       Abort;
     end;
  IdFTP1.Put('c:\pippo.tif','pippo.tif',False);
end;

When i click speedbutton2, the file is not copied and i read this message
"Invalid class typecast".

Someone can tell me, how can i change my code?

Thanks

Replies:

www.cryer.info
Managed Newsgroup Archive