Windows 下的服务可以做什么? [英] What can Services do under Windows?

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

问题描述

是否有人对 XP 下 Windows 服务的功能有很好的指导?特别是,我试图找出当作为服务运行的程序尝试打开窗口但没有获得与桌面交互的权限时会发生什么.

Does anyone have a good guide to capabilities of Windows Services under XP? In particular, I am trying to find out what happens when a program being run as a service tries to open windows, but hasn't been given permission to interact with the desktop.

基本上,我有一个程序是/曾经是 GUI 应用程序,它应该能够作为服务运行以进行长期后台处理.重写程序以在进行后台处理时不显示 GUI 元素是一项重大工作,因此我想看看是否只有一种方法可以忽略 UI 元素.只要不打开太多窗口,它现在就可以工作.我试图弄清楚我可能会遇到什么限制.理想情况下,会有一个 MSDN 页面讨论这个问题,但我还没有找到.

Basically, I have a program that is/was a GUI application, that should be able to run as a service for long term background processing. Rewriting the program to not display the GUI elements when doing background processing is a major effort, so I'd like to see if there is just a way to ignore the UI elements. It is sort of working now, as long as too many windows aren't opened. I'm trying to figure out what limits I might be running into. Ideally, there would be an MSDN page that discusses this, but I've had no luck finding one yet.

推荐答案

通常,服务应该设计为没有任何可见的 UI.服务的全部意义在于在后台运行,没有 UI,无人看管.(想想 SQL Server、IIS 等)

Generally, services should be designed to not have any visible UI. The entire point of a service is to run in the background, without UI, unattended. (Think SQL Server, IIS, etc.)

在大多数情况下,如果需要 GUI,则单独的应用程序控制服务的操作.(继续我刚刚提到的示例,SQL Server Management Studio、IIS Manager 等)这些单独的应用程序配置和操作服务(有时,如果需要,还可以退回所述服务).

In most scenarios, a separate application controls the service's operation, should a GUI be needed. (Continuing the samples I just mentioned, SQL Server Management Studio, IIS Manager, etc.) These separate applications configure and manipulate the service (and occasionally, if needed, bounce said service).

如果您的服务偶尔需要 UI,并且不能将 UI 隔离到控制应用程序,那么您可能应该重新考虑您开始使用服务的事实.也许驻留在系统通知区域的 UI 应用程序是正确的模式?(例如,Windows Live Communicator.)

If your service requires occasional UI, and said UI can't be isolated to a control app, then you probably should reconsider the fact that you're using a service to begin with. Perhaps a UI application which resides in the system notification area is the right pattern to use? (E.G., Windows Live Communicator.)

这篇关于Windows 下的服务可以做什么?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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