Solved

TFTP in a console application ?

Posted on 1997-05-14
2
266 Views
Last Modified: 2010-04-04
I need to use the TFTP components from the Internet Solution
Pack (given with Delphi 2.0 Client/Server Release) in an
application without a form.
I want to know how to implement this, how to implement the
events of a non-visual component out of a form.
For now, here is what I tried, it don't work !
program ftpsrv;

uses
  SysUtils,
  Classes,
  Windows,
  WinSvc,
  NTObj,
  SvcObj,
  DB,ISP;

type
{$R *.RES}
var ftpbdd : TDataBase;
    ftpc : TFTP;


{ this is never called unless FTpStateChanged is an event
of the component }
procedure ftpc.FTPStateChanged(Sender: TObject; State: Smallint);
begin
  with FTP do
    case State of
      prcConnecting   : MessageDLG('Connecting',mtInformation,[mbOK],0);
      prcResolvingHost: MessageDLG('Connecting',mtInformation,[mbOK],0);
      prcHostResolved : MessageDLG('Host resolved',mtInformation,[mbOK],0);
      prcConnected    : MessageDLG('Connected',mtInformation,[mbOK],0);
      prcDisconnecting: ;
      prcDisconnected : ;
    end;
end;

begin
ftpc:=TFTP.Create(Nil);
ftpc.Password:='3il@hol.fr';
ftpc.RemoteHost:='192.9.200.2';
ftpc.RemotePort:=21;
ftpc.UserId:='anonymous';
ftpc.Connect('192.9.200.2',21);
{in fact i've look at the State variable, my component
never connect}
ftpc.ChangeDir('/');
ftpc.RemoteFile:='docserveurNT4.htm';
ftpc.GetFile('./docserveurNT4.htm','c:\essai.htm');
MessageBeep(Word(-1));
end.

Thanks for your help 8°)
0
Comment
Question by:apostoly
2 Comments
 
LVL 4

Accepted Solution

by:
erajoj earned 200 total points
ID: 1336230
Try this:
   .
   .
   .
procedure FTPStateChanged(Sender: TObject; State: Smallint);
begin
  with (Sender as TFTP) do
  case State of
    prcConnecting   : MessageDLG('Connecting',mtInformation,[mbOK],0);
    prcResolvingHost: MessageDLG('Connecting',mtInformation,[mbOK],0);
    prcHostResolved : MessageDLG('Host resolved',mtInformation,[mbOK],0);
    prcConnected    : MessageDLG('Connected',mtInformation,[mbOK],0);
    prcDisconnecting: ;
    prcDisconnected : ;
  end;
end;
   .
   .
   .
ftpc.OnStateChanged := FTPStateChanged;
   .
   .
   .

Hope this helps!

///John
0
 

Author Comment

by:apostoly
ID: 1336231
thanks a lot, I didn't know how to react the events
0

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Objective: - This article will help user in how to convert their numeric value become words. How to use 1. You can copy this code in your Unit as function 2. than you can perform your function by type this code The Code   (CODE) The Im…
Introduction I have seen many questions in this Delphi topic area where queries in threads are needed or suggested. I know bumped into a similar need. This article will address some of the concepts when dealing with a multithreaded delphi database…
The Email Laundry PDF encryption service allows companies to send confidential encrypted  emails to anybody. The PDF document can also contain attachments that are embedded in the encrypted PDF. The password is randomly generated by The Email Laundr…
Finds all prime numbers in a range requested and places them in a public primes() array. I've demostrated a template size of 30 (2 * 3 * 5) but larger templates can be built such 210  (2 * 3 * 5 * 7) or 2310  (2 * 3 * 5 * 7 * 11). The larger templa…

733 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question