Using MFC in a Windows service?

I am starting to develop a Windows service. I want to use some classes of my own that are little dependent on some MFC classes, such as CString, CSocket, CArchive, CMemFile and CObject. MSDN says that you need to be very careful about which parts of the MFC you use in the Windows service, but do not specify them and do not click, t describes the problems that may occur.

My questions:

  • What parts of the MFC can I use?
  • What problems can I expect using MFC?
  • What parts of the Windows service are critical to using MFC?
  • Is it recommended to use ATL instead of the MFC service for Windows?
+5
source share
3 answers

I'm not sure what they mean in the MSDN article. Until you use any GUI functionality, everything will be fine - but this is a common problem when developing services.

With that said, ATL has functionality specifically designed to create IIRC services, so you might be better off using this.

To answer your questions (as far as I know):

1) the ones you indicated are not a problem.

2) I assume that they mean problems with synchronization with user interface components. As long as you don't use any CWnd-derived classes, you'll be fine.

3) do not understand the issue.

4) . , ATL , , . . CAtlServiceModuleT. - , CString MFC ATL , ATL . CArchive, , CObject, , ATL. "" .

+4

( , , , MFC - ...)

, , Window. . , , pre-exisiting MFC Windows. , , - ? ! ( , - )

CObject? id , RTTI (dynamic_cast ..)

CString, CString, , ATL , , MFC ATL. std::string. , , - std::string, , CString. (EDIT: code - !!, ...)

CArchive, CMemFile: ?

, , ATL . MFC (-!) ATL? . COM, . COM, CAtlServiceModuleT ..... ....

+3

And one more bad thing about MFC in services that I just tried trying to turn a regular MFC-ATL application into a service: using AfxConnectionAdvise () is actually useless without the Window procedure. The threads in my service are just regular message flows. I believe this is why I never get events fired from another COM server that I developed. This other COM server hangs on Fire_xxxEvent (), causing a big mess throughout the system.

0
source

All Articles