Solved

TFTP in a console application ?

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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

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…
Have you ever had your Delphi form/application just hanging while waiting for data to load? This is the article to read if you want to learn some things about adding threads for data loading in the background. First, I'll setup a general applica…
This video demonstrates how to create an example email signature rule for a department in a company using CodeTwo Exchange Rules. The signature will be inserted beneath users' latest emails in conversations and will be displayed in users' Sent Items…
This is a video that shows how the OnPage alerts system integrates into ConnectWise, how a trigger is set, how a page is sent via the trigger, and how the SENT, DELIVERED, READ & REPLIED receipts get entered into the internal tab of the ConnectWise …

932 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

10 Experts available now in Live!

Get 1:1 Help Now