在Windows服务中使用MFC? [英] Using MFC in Windows service?

查看:192
本文介绍了在Windows服务中使用MFC?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我开始开发Windows服务.我想使用自己的一些类,这些类对某些MFC类(如CString,CSocket,CArchive,CMemFile和CObject)的依赖性很小. MSDN 说,您需要非常小心Windows服务中使用的MFC片段,但未指定它,也未描述可能发生的问题.

I'm starting to develop a Windows service. I want to use some classes from my own, that has little dependencies to some MFC classes like CString, CSocket, CArchive, CMemFile and CObject. MSDN says you need to be very careful about which pieces of MFC you use in the Windows service, but don't specifies it and don't describes the problems that can occur.

我的问题是:

  • 可以使用哪些MFC?
  • 使用MFC,我会遇到什么问题?
  • Windows服务的哪些部分对于MFC的使用至关重要?
  • 是否建议使用ATL代替MFC for Windows服务?

推荐答案

我不确定它们在MSDN文章中的含义.只要您不使用任何GUI功能,就可以了-但这是开发服务时的一般设计问题.

I'm not sure what they mean in teh MSDN article. As long as you don't use any of the GUI functionality you'll be fine - but that's a general design issue when developing services.

话虽这么说,ATL具有专门为构建服务IIRC而设计的功能,所以使用它可能会更好.

That being said, ATL has functionality specifically designed for building services IIRC so you may be better off using that.

(据我所知)回答您的问题:

To answer your questions (to the best of my knowledge):

1)您指定的内容没问题.

1) the ones you specify are no problem.

2)我想这意味着与UI组件的同步问题.只要您不使用任何CWnd派生的类,就可以了.

2) I guess they mean synchronization issues with UI components. As long as you don't use any CWnd-derived classes you'll be fine.

3)不明白这个问题.

3) don't understand the question.

4)之前见过,加上ATL更轻巧,因此您将不必分配太多内容,并提供内置功能,这将减轻开发服务的麻烦.参见例如CAtlServiceModuleT.由于CString在MFC和ATL之间共享,而ATL本身具有用于套接字编程和内存文件映射的类,因此您仍然可以大部分使用自己的类.它没有CArchive的等效项,而且我不确定您在CObject中使用了什么功能,因此我不能说ATL中是否有等效项.因此,总而言之,我会对这个问题说是".

4) See before, plus ATL is more lightweight so you'll have to distribute less, and provides build-in functionality that'll make it less of a pain to develop the service. See e.g. CAtlServiceModuleT. You'll still be able to mostly use your own classes, as CString is shared between MFC and ATL nowadays and ATL has classes for socket programming and memory file mapping itself. It doesn't have an equivalent for CArchive, and I'm not sure what functionality you use in CObject so I can't say whether there's an equivalent in ATL. So to conclude, I'd say 'yes' to this question.

这篇关于在Windows服务中使用MFC?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆