Solved

TFTP in a console application ?

Posted on 1997-05-14
2
240 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
Comment Utility
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
Comment Utility
thanks a lot, I didn't know how to react the events
0

Featured Post

Maximize Your Threat Intelligence Reporting

Reporting is one of the most important and least talked about aspects of a world-class threat intelligence program. Here’s how to do it right.

Join & Write a Comment

Introduction Raise your hands if you were as upset with FireMonkey as I was when I discovered that there was no TListview.  I use TListView in almost all of my applications I've written, and I was not going to compromise by resorting to TStringGrid…
In my programming career I have only very rarely run into situations where operator overloading would be of any use in my work.  Normally those situations involved math with either overly large numbers (hundreds of thousands of digits or accuracy re…
Here's a very brief overview of the methods PRTG Network Monitor (https://www.paessler.com/prtg) offers for monitoring bandwidth, to help you decide which methods you´d like to investigate in more detail.  The methods are covered in more detail in o…
Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…

771 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

Need Help in Real-Time?

Connect with top rated Experts

8 Experts available now in Live!

Get 1:1 Help Now