Hi,
I have a windows forms app. and I would like to use it as a windows service. How can I do it?
Best Regards.
Loading
Know the answer? Post it. Somebody with the same question will find it here.
Answer a question in the forums and earn +20 SHARP for every answer.
See unanswered questions
DevSocialUpcoming · 3rd editionAI Agents ConferenceDec 1–3, 2026Live onlineFree to attend4days leftRegister
VulpesRank #55 · 29.2K reputationPosted Mar 12, 2012, 2:32 AM EDT
Moreover, it's generally thought best if services don't interact with the desktop at all though there is a flag in the service's properties in the Management console which enables you to do this if you must.
Of course, none of this prevents you from rewriting the non-GUI aspects of the WF application as a service where feasible.
RaysefoRank #4,173 · 360 reputationPosted Mar 12, 2012, 4:07 AM EDT
Actually my UI is not visible so I don't care about the UI , since this applicaiton gets the key strokes and screen shots in background. Now do I have chance to convert?
Best Regards.
VulpesRank #55 · 29.2K reputationPosted Mar 12, 2012, 8:02 AM EDT
Sam HobbsRank #107 · 20.5K reputationPosted Mar 12, 2012, 7:41 PM EDT
An alternative might be a system-wide low-level keyboard hook. I do not know if you can install them from a service but if you can then you are in business. Believe it or not, the Microsoft web site is having problems at the moment, at least for me so I cannot check it for you. I think the function to install hooks is SetWindowsSystemHookEx or something very much like that. You can use a system-wide low-level keyboard hook in C# so if you can do that in a service then you can test your code without making it a service then use the same code in a service, as long as it is allowed in a service.
I don't know the details of what you are doing to get "a screen-shot" but that will be more complicated. You might be able to solve that problem by another system-wide hook to hook messages sent to windows but in order to do that you must use a little unmanaged code (C++); there is no way to get around the need to have some unmanaged code for that. Without knowing what you need to do, my guess is that processing messages would be too complicated.
You can probably access windows (Windows windows) at the device driver level, but it might require extra work to relate the data to the application.
Sam HobbsRank #107 · 20.5K reputationPosted Mar 12, 2012, 7:42 PM EDT