Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Program onclose events

Status
Not open for further replies.

paubri

Programmer
Apr 25, 2005
21
ZA
Hi. I was wondering code programs run when the close other than that in the onclose event. My program runs fine, but it come up with an access violation when I close it. How could I prevent this?

Any help would be appreciated.

British
 
don't exactly understand your question, could you show some code to describe the problem?

--------------------------------------
What You See Is What You Get
 
I have a program that I am sending an e-mail through using MAPI. The sending of the e-mails works fine, but when I close the program, it comes up with an error message saying:

Code:
Project Project1.exe raised exception class EAccessViolation with message 'Access violation at address 7649F877. Read at address 7649F877'. Process stopped. Use step or run to continue.

It does this every time, but only when I have sent an e-mail. I was thinking that it must be one of the variables the program uses to send the message that it is trying to access before closing the program, but I am not trying to access any. I think it must be something the program is automatically trying to do before closing.
 
General points
Are there any timers running that might be involved with you email code?
Or any flags that are set by the email handler that would indicate the system has finished sending mail?
Are you creating any objects that are not being freed prior to closing the program?



Steve: Delphi a feersum engin indeed.
 
It could also be that on closing you have some code to free an object that's already been freed. I always use the following code to free an object:
Code:
if Assigned(MyObject) then
  FreeAndNil(MyObject);
By calling Assigned I am checking that MyObject is not nil i.e. make sure it hasn't already been freed.
By using FreeAndNil I am ensuring that MyObject is freed and set to nil.

Clive [infinity]
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
"To err is human, but to really foul things up you need a computer."
Paul Ehrlich
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
To get the best answers from this forum see: faq102-5096
 
paubri,

try to stay in the same thread if it's about the same problem.
guys, look here : thread102-1068750
I propose to close this thread and move further discussion to the other thread

-----------------------------------------------------
What You See Is What You Get
Never underestimate tha powah of tha google!
 
Thanks Clive. What you said seems to have worked. I was trying to free one of the variables earlier on, and it was doing it again when the program closed.
 
My comments were based on experience!!! I've done that many times and eventually I've learnt from my mistakes!!! ;-)

Clive [infinity]
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
"To err is human, but to really foul things up you need a computer."
Paul Ehrlich
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
To get the best answers from this forum see: faq102-5096
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top