在Windows服务中显示表单 [英] Show form in Windows Service
本文介绍了在Windows服务中显示表单的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我需要使用Windows服务显示我的表单。我的表单是一个弹出警报,因为没有用户控件。它只是一个提醒的弹出窗口。
我需要在服务开始时启动警报
请帮忙。
提前谢谢
解决方案
参见如何通过Window Service运行Window Application? [ ^ ]
您无法从Windows服务显示表单,也无法从Windows服务运行GUI应用程序。原因是服务可以在没有用户登录的情况下运行。您应该做的是创建系统托盘应用程序(将其配置为在用户登录时运行),然后您可以让应用程序通知服务当它可用时,允许服务将通知推送给它。
我写了一篇文章,其中有一个Windows服务与系统托盘应用程序通信。它可能会或可能不会帮助您:
Synchronicity - 文件夹同步应用程序 [ ^ ]
伙计这是最高阶的线程坏死,但这根本不是真的。您可以通过收集用户的所有可用SessionID并使用wtsapi32.dll通过STAThread调度来编写是/否消息框
c# - .NET Windows服务(WTSSendMessage):在XP上显示消息但不是Windows 7 - 堆栈溢出 [ ^ ]
Hi,
I need to show my form with windows service. My form is a popup alert in that there is no user control. Its just a popup form for alert.
I need to start the alert when my service starts
Pls help.
Thankz in advance
解决方案
See How to run Window Application through Window Service?[^]
You can't show a form from a Windows Service, and you can't run a GUI application from a Windows Service. The reason is that a service can be running while no user is logged in. What you *should* do is create a system tray application (configure it to run when a user logs in), and then you can have the app notify the service when it's available, allowing the service to push notifications to it.
I wrote an article that has a windows service communicating with a system tray app. It may or may not help you:
Synchronicity - A Folder Synchronizing Application[^]
guys this is thread necromancy of the highest order, but this is simply NOT true. You can write yes /no messageboxes by collecting all available SessionID's of the users and dispatching using wtsapi32.dll via the STAThread
c# - .NET Windows Services (WTSSendMessage) : Displays message on XP but not Windows 7 - Stack Overflow[^]
这篇关于在Windows服务中显示表单的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文