Click here to Skip to main content
15,867,453 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi,

In order to close the .exe file, i am using CWinApp::ExitInstance().
The Problem here is, ExitInstance() method is being called and the return value is zero. But when i check in taskmanager the exe is still running. Operating system used is Windows 7. Also it was working fine in windows XP.
Posted
Updated 28-Dec-10 22:30pm
v2
Comments
ShilpiP 29-Dec-10 6:06am    
Did you run your application as an admin or set RequireAdministrator ??
SrikanthSriSri 30-Dec-10 4:46am    
I am running it in administrator account anly.
Richard MacCutchan 30-Dec-10 5:49am    
Re-read what I have suggested in my latest posting, check the rules for this API call, and use your debugger to see exactly what is happening in your code. Since you have not shown any of the code you are using it is impossible to suggest anything else.

I don't think that is correct; take a look here[^] for information on this member function.
 
Share this answer
 
Comments
SrikanthSriSri 30-Dec-10 3:36am    
Thanks for your help.
But with the same API ExitInstance() the exe is getting killed in customer version but not happening in developer version.
Any Idea y ? - SrikanthSriSri 2 mins ago . Also it was working Fine in Win XP but not in Win 7.
To close an application you need to send quit message.
Calling ExitInstance won't help. try calling PostQuitMessage function http://msdn.microsoft.com/en-us/library/ms644945(v=vs.85).aspx[^](assuming your application has only single thread).
 
Share this answer
 
v2
Comments
SrikanthSriSri 30-Dec-10 3:34am    
Thanks for your help.
But with the same API ExitInstance() the exe is getting killed in customer version but not happening in developer version.
Any Idea y ?
SrikanthSriSri 30-Dec-10 3:36am    
Also it was working Fine in Win XP but not in Win 7.
SrikanthSriSri 30-Dec-10 4:28am    
I mean to say with the same API i am able to exit the instance of the application called by the framework within the run member function.
jk chan 31-Dec-10 12:02pm    
if your application is single threaded ExitInstance will get called. thats sure. Debug!!
Well it looks like you downvoted me because you did not like my answer, or maybe the link I provided.

SrikanthSriSri wrote: But with the same API ExitInstance() the exe is getting killed in customer version but not happening in developer version. Any Idea y ?


Yes, your code is wrong. The fact that it sometimes works under certain circumstances does not mean that the code is correct, only that the error is not showing up. If you took the time to refer to the link I posted you will see the following sentence:
The ExitInstance member function of class CWinApp is called each time a copy of your application terminates, usually as a result of the user quitting the application.


That suggests to me that calling this function does not necessarily terminate the program. A spell with the debugger should confirm this.

 
Share this answer
 
v2
Comments
SrikanthSriSri 30-Dec-10 4:29am    
I mean to say with the same API i am able to exit the instance of the application called by the framework within the run member function.
SrikanthSriSri 30-Dec-10 4:31am    
So please let me know what i must do to resolve this issue.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900