Click here to Skip to main content
15,890,825 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi,
I have an MFC application and that starts execution when windows starts.When the application ends, It keeps a log file in temp folder. Some times,when improper shut down occurs, my application ends without writing the log file. How can I remove this situation? how can we know system status like shut down, system locked etc.. Please give some hints.

Thanks
Mithun Nair
Posted
Updated 18-Jan-11 13:39pm
v2

Write the log immediately, whenever some change occurs? Or update it periodically, like MS Word's auto-save?
 
Share this answer
 
Comments
Espen Harlinn 18-Jan-11 8:50am    
5+ Write immediately to the log, what if the app crashes?
Indivara 18-Jan-11 19:38pm    
Too bad, then :) (but not asked in the question)
The answer below is better. Didn't know that one. Doesn't cover a system hung situation though.
Drivers use this
http://msdn.microsoft.com/en-us/library/ff566401.aspx
but I don't think it would work in an application.
Espen Harlinn 19-Jan-11 5:39am    
I know it wasn't asked in the question :) I just thought it's a good advice. When I work in C++ I usually leverage ACE, http://www.cs.wustl.edu/~schmidt/ACE.html, and make extensive use of it's logging facilities. I've had no performance problems using this excellent library, and there are lots of other goodies too :)
Indivara 19-Jan-11 7:05am    
That looks good, I'm going to try it out some time soon. Have a virtual 5!
Hi,

have a look at the WM_QUERYENDSESSION message:
http://msdn.microsoft.com/en-us/library/aa376890%28VS.85%29.aspx[^
 
Share this answer
 
Comments
Espen Harlinn 18-Jan-11 8:48am    
5+ Good "hintz" :)

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