login about faq

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;

asked Mar 14 at 13:22

rodrigomorais's gravatar image

rodrigomorais
1


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();

link

answered Mar 14 at 19:12

chilkat's gravatar image

chilkat ♦♦
11.8k316358420

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.

link

answered Mar 15 at 08:48

rodrigomorais's gravatar image

rodrigomorais
1

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:

  1. Your program calls a Chilkat method (such as ftp2.PutFile)
  2. The program's thread of execution is now inside the Chilkat PutFile method
  3. PutFile makes a callback to your Delphi's callback method.
  4. The programs thread of execution is now inside your Delphi's callback method.
  5. Your callback method returns.
  6. The program's thread of execution is now back inside the Chilkat PutFile method, continuing on..
  7. This can repeat many times -- until finally the ftp2.PutFile method returns, and the thread of execution is back inside your application, continuing with the statements that follow the call to PutFile.

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.

link

answered Mar 15 at 08:58

chilkat's gravatar image

chilkat ♦♦
11.8k316358420

Your answer
toggle preview

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here

By RSS:

Answers

Answers and Comments

Markdown Basics

  • *italic* or __italic__
  • **bold** or __bold__
  • link:[text](http://url.com/ "title")
  • image?![alt text](/path/img.jpg "title")
  • numbered list: 1. Foo 2. Bar
  • to add a line break simply add two spaces to where you would like the new line to be.
  • basic HTML tags are also supported

Tags:

×96
×56
×4

Asked: Mar 14 at 13:22

Seen: 439 times

Last updated: Mar 15 at 08:58

powered by OSQA