Link to home
Start Free TrialLog in
Avatar of delphipal
delphipal

asked on

anydelphi programmer to solve my problem

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.



Avatar of Jason Sweby
Jason Sweby
Flag of United Kingdom of Great Britain and Northern Ireland image

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.

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?
Avatar of psycho_cat_69
psycho_cat_69

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
Avatar of Eddie Shipman
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;

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.

I recommend looking at IP*Works from /n Software.
But IP*Works isn't free and their support is suspect.
ASKER CERTIFIED SOLUTION
Avatar of shyampaliyath
shyampaliyath

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial