C++ 6.0 MFC app running as service, and ExitInstance
Posted on 2009-07-07
I have a small application built with VC++ 6.0 that historically ran as a standalone executable, a small dialog on the desktop. When one clicks File->Close or the X in the upper right, CMyApp::ExitInstance() is called, allowing me to shut everything down in the proper order. This all works just as it should. All computers are running on XP Pro SP3
We are now installing it as a service. We're using 'srvany.exe' to set it up as a service and for the most part this too seems to work just fine.
However, it seems that when the user shuts down the computer (Start Menu->Shut Down), or, simply stops the service in the services dialog, my logging is showing that ExitInstance is not being called.
Is there a hook or something I can add to my MFC project so that ExitInstance is called, and fully executed, when the service is stopped? (which I would assume would cover system shut-down)