如何在Windows服务中显示窗体表单应用程序? [英] How Do I Display Window form application in windows service ?

查看:136
本文介绍了如何在Windows服务中显示窗体表单应用程序?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述







我创建了Windows_Form_Application,我需要在Windows启动后在后台运行这个应用程序...(Don不要说,把你的应用程序放在启动状态。通过添加Windows服务应用程序可以在后台运行Form应用程序吗?







提前致谢..

Hi,


I have Created Windows_Form_Application, I need to run this app in background whenever windows starts... (Don't say, Put your Application in Start up). By adding Windows Service application Can it be possible to run Form application in background?



Thanks in advance..

推荐答案

Windows服务没有应用程序消息泵,因此无法显示任何图形用户界面。

因此,服务似乎不是解决方案。



你有几种选择:

- 你保留你的用户界面但不能把它作为服务运行。

- 你扔UI离开,只保留功能部分(服务必须完成的任务)。

- 您保留实际应用程序并开发第二个项目,该项目将作为服务运行。
A Windows service has no application message pump, thus it is unable to display whatever graphical UI.
So a service does not seem to be the solution here.

You have several choices:
- you keep your UI but won't be able to run it as service.
- you throw the UI away, only keeping the functional part (what the service will have to accomplish).
- you keep your actual application and develop a second project that will be the program that is run as a service.


您无法将交互式应用程序(Windows窗体)作为服务运行,因为它只会坐在那里等待永远不会发生的用户输入。为什么?因为作为服务运行的应用程序是在用户看不到的桌面下运行的。



由于应用程序将启动,您也无法从服务应用程序启动交互式应用程序在服务桌面上,而不是用户。



要在Windows启动时启动(在任何人登录控制台之前),你必须将应用程序重写为服务应用程序,而不是Windows窗体。根本没有任何用户界面。



如果您需要与服务进行用户交互,请编写一个单独的Windows窗体应用程序,用户可以启动该应用程序与之通信服务通过一些进程间通信方法,如命名管道。
You cannot run an interactive application (Windows Forms) as a service as it will just sit there waiting for user input that will never happen. Why? Because applications running as a service are running under a desktop separate that the user cannot see.

You also cannot launch an interactive application from a service application as the application will launch on the service desktop, not the users.

To launch at Windows startup (before anyone logs into the console), you MUST rewrite the application as a service app, not Windows Forms. There cannot be any user interface at all.

If you need to have user interaction with the service, write a separate Windows Forms application that the user can launch that communicates with the service through some of Inter-Process Communication method, such as named pipes.


这篇关于如何在Windows服务中显示窗体表单应用程序?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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