Click to See Complete Forum and Search --> : WinApplication & Service?
AgentSmithers
October 16th, 2009, 01:49 PM
Ive made a Windows Application that uses a GUI and performs basic task with WinMain... Is it possible to add the ability for my exe to act as a service as well by adding
void _ServiceMain( void* )
to the project or would it be far more complicated then that?
Arjay
October 16th, 2009, 09:10 PM
Well, the first thing is that a service shouldn't display any UI. In older OS's (pre-Vista), you could register the service to interact with the desktop, but that option isn't available or recommended in Vista, 2008 Server, or Win7.
It's probably preferable to split up your app functionality into code that you can put into a service and the UI code, then use some sort of interprocess communication to allow the UI app to communicate with the service.
Btw, a great starting point for a service is to create a service application with ATL.
Igor Vartanov
October 17th, 2009, 02:42 AM
In one of my recent projects I made some MFC server (legacy application with moderate GUI but sophisticated server logic) be able to run service mode, so it's possible, of course, but not trivial for sure, as it took me all my skills in Windows services. And due to this it cannot be explained in a couple of "do this and that" statements.
I completely agree with Arjay about splitting application (if this is an option for you, of course), but unfortunately cannot support his point about ATL service being a great starting point for beginners. But never mind, I oppose him in this question really long time, so you only need to know that there are more than one opinion about this point. :)
Arjay
October 17th, 2009, 03:59 AM
Fortunately, we have a cordial disagreement. :) If I had been clever enough to write my own service framework like Igor has, I would be inclined to use it. For me, I have to go with ATL. Both get the job done quite a bit easier than coding the service from scratch.
codeguru.com
Copyright Internet.com Inc., All Rights Reserved.