Solved

TFTP in a console application ?

Posted on 1997-05-14
2
256 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

Master Your Team's Linux and Cloud Stack!

The average business loses $13.5M per year to ineffective training (per 1,000 employees). Keep ahead of the competition and combine in-person quality with online cost and flexibility by training with Linux Academy.

Question has a verified solution.

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

This article explains how to create forms/units independent of other forms/units object names in a delphi project. Have you ever created a form for user input in a Delphi project and then had the need to have that same form in a other Delphi proj…
Hello everybody This Article will show you how to validate number with TEdit control, What's the TEdit control? TEdit is a standard Windows edit control on a form, it allows to user to write, read and copy/paste single line of text. Usua…
Although Jacob Bernoulli (1654-1705) has been credited as the creator of "Binomial Distribution Table", Gottfried Leibniz (1646-1716) did his dissertation on the subject in 1666; Leibniz you may recall is the co-inventor of "Calculus" and beat Isaac…
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…

803 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