Question:
i need implement a method of callback but i'm having problems in way like am implementing. Can someone help me?
procedure TfrmPrincipal.EnviarArquivo;
var
intf: IDispatch;
ftp2: OleVariant;
begin
try
intf := CreateOleObject('Chilkat95_0.Ftp2');
ftp2 := intf;
try
// Callback
ftp2.onProgressInfo := ftp_onProgressInfo;
if ftp2.unlockComponent('unlocked') <> 1 then
raise Exception.Create(ftp2.LastErrorText);
ftp2.HostName := edtHostName.Text;
ftp2.UserName := edtUserName.Text;
ftp2.PassWord := edtPassWord.Text;
ftp2.Port := StrToInt(edtPort.Text);
ftp2.Passive := 1;
if ftp2.Connect <> 1 then
raise Exception.Create(ftp2.LastErrorText);
if (ftp2.ChangeRemoteDir('IN') <> 1) then
raise Exception.Create(ftp2.LastErrorText);
if (ftp2.PutFile(odlgArquivo.FileName,
ExtractFileName(odlgArquivo.FileName)) <> 1) then
raise Exception.Create(ftp2.LastErrorText);
mmLog.Lines.Add('File sent!!!')
except
on e:exception do
mmLog.Lines.Add(e.Message);
end;
finally
VarClear(ftp2);
end;
end;
You can find event help/examples in the online reference documentation. For example, go to http://www.chilkatsoft.com/refdoc/delphiFtp2Ref.html and then scroll all the way to the bottom.
Also, the string you're passing to CreateObject is wrong. It should be:
CreateOleObject('Chilkat_9_5_0.Ftp2');or better yet, the object creation should be:
var obj: TChilkatFtp2; ... begin obj := TChilkatFtp2.Create(Self); ... // When finished, free the object instance. obj.Free();
thanks for answer, but my problem is implementation of callback event, i don't know how pass the event to ftp2!
The event is ProgressInfo.
I don't use TLB.pas.
Your program doesn't generate the event.
The "event callbacks" are just callbacks. They are callbacks from within the Chilkat DLL back to the Delphi application. The flow of control is like this:
I don't know how to setup the callback function without the TLB.pas. In other words, you should use Delphi to generate the wrappers (i.e. TLB.pas) so that you can use TChilkatFtp2 and setup callbacks in the prescribed way.