Click to See Complete Forum and Search --> : Creating Service with MFC


Daeriel
February 11th, 2003, 08:06 PM
Hi everyone,

I need to create MFC service application with MFC based GUI and document/view support. The problem is that I cannot override WinMain function to incapsulate MFC initialization or TWinApp::Run call within Service entry point, called through control dispatcher (using VS.NET).

When I define my own WinMain the linker doesn't include it instead of MFC WinMain. I cannot directly specify Linker Entry Point because I must fully implement CRT entry point with certain initialization/finalization code.

I got another point though. I've created MFC application, then changed the linker settings to console mode, then implemented _tmain() function which calls the service control dispatcher, and enclosed the whole MFC/Document/View initialization and message loop (TWinApp::Run()) within ServiceStart function.
In this case application is compiled without any errors, but when I just start it in the debug mode (without call to Control dispatcher, I just call ServiceMain from _tmain()) the application is running without errors and when I close it, it generates access violation on deinitializing document/view part.

What can I do?