We help IT Professionals succeed at work.

anydelphi programmer to solve my problem

delphipal
delphipal asked
on
i am very new delhiprogrammer started around for 2months. i am doing in delphi ver 3. i have working on the ftp project in delphi for the past two weeks. in this i will be connecting to the remote server through dial up connection. the problem is there in the exit button which i will click after the file transfer is over. the code for this is written as follows

procedure Tftpfrm.btnexitClick(Sender: TObject);
begin
     ftp1.Cancel;
     application.ProcessMessages;
     close;
end;

procedure Tftpfrm.FormClose(Sender: TObject; var Action: TCloseAction);
begin
if ftp1.busy then
begin
    ftp1.cancel;
    ftp1.quit;
    while ftp1.busy do
         application.process;
    close;
end;
end;
the problem occurs in the close; statement i.e. OnFormClose where an exception occurs as (i.e. EAccessViolation exception) when in tried to handle it through the exception handling it shows me another error like "this program has performed an illegal operation and if this persist aontact the program vendor." and also shows an error in the NMSCKN.dll which is totlly absurb for me.

even i took out all the above coding from the exit and just put

ftp1.cancel
close;

the same problem continues.

NOTE: the ftp is properly exitted i.e. it goes to the state 5 and state 6.
any clues?????
PLZ guide me as soon as possilble
thanking u.
delphipal.



Comment
Watch Question

Jason SwebyTechnical Director
CERTIFIED EXPERT

Commented:
I don't know what FTP component you are using, but is it possible that checking its Busy property after calling its Quit method is causing some problem? And what is Application.Busy? I couldn't find a Busy property or method for TApplication, should this be Application.ProcessMessages?

J.

Commented:

if ftp1.busy then
                     begin
                        ftp1.cancel;
                        ftp1.quit;
                        while ftp1.busy do  <<<<<<<I'm not sure what this does, but ftp1 has already quit
                             application.process;
                        close;
                     end;

 If ftp1.quit  is the same as  ftp1.free, there is your access violation.  Try taking out the "while" statement.

As to the FTP1.Cancel, ftp1 may have already been freed somewhere else in your program.  Calling a component who's memory has been freed will give an access violation.  

Is the NMSCKN.dll  used by  your ftp component?
i must agree with martin_q!

Trace into the ftp1.quit procedure to see if there's a free on your object (ftp1).  If that's the case!  remove the line "While ftp1.busy do" from your code and that'll do!

I'm 99% sure that's the problem!

Mark
Eddie ShipmanAll-around developer
CERTIFIED EXPERT

Commented:
From this mention: "NMSCKN.dll", I would suspect he is
using TNMFTP.

BTW, You need to do it this way:

procedure Tftpfrm.btnexitClick(Sender: TObject);
begin
  FTP1.Cancel;
  FTP1.Disconnect; // not FTP1.Quit
end;

And then in FTP1 component's On Disconnect event do this:

procedure TForm1.NMFTP1Disconnect(Sender: TObject);
begin
  Close;
end;

Eddie ShipmanAll-around developer
CERTIFIED EXPERT

Commented:
FWIW (for what it's worth) I'd drop the use of the NMFTP
component and download Winshoes for Delphi3 from:
http://www.nevrona.com

It is easier to work with an not buggy like the NetMasters
components.

CERTIFIED EXPERT
Top Expert 2014

Commented:
I recommend looking at IP*Works from /n Software.
Eddie ShipmanAll-around developer
CERTIFIED EXPERT

Commented:
But IP*Works isn't free and their support is suspect.
this happens when all the files are not transferred through ftp. this means that ftp connection has got disconnected and u r trying to exit the ftp component.
thus u get this error.in that case form close is more than enough and ftp1.exit should not be executed.

Explore More ContentExplore courses, solutions, and other research materials related to this topic.