Solved

TFTP in a console application ?

Posted on 1997-05-14
2
272 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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

Independent Software Vendors: 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

In this tutorial I will show you how to use the Windows Speech API in Delphi. I will only cover basic functions such as text to speech and controlling the speed of the speech. SAPI Installation First you need to install the SAPI type library, th…
Creating an auto free TStringList The TStringList is a basic and frequently used object in Delphi. On many occasions, you may want to create a temporary list, process some items in the list and be done with the list. In such cases, you have to…
There's a multitude of different network monitoring solutions out there, and you're probably wondering what makes NetCrunch so special. It's completely agentless, but does let you create an agent, if you desire. It offers powerful scalability …
NetCrunch network monitor is a highly extensive platform for network monitoring and alert generation. In this video you'll see a live demo of NetCrunch with most notable features explained in a walk-through manner. You'll also get to know the philos…

728 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