带有WPF管理工具的Windows服务

发布于 2024-09-10 08:17:53 字数 202 浏览 6 评论 0原文

我正在尝试在 .net 中使用 C# 创建一个 Windows 服务,该服务在用户登录之前运行... 然后,当用户登录时,系统托盘中(时钟旁边)应出现一个符号,以向用户显示该服务正在运行。 通过双击该符号,应该向用户显示一个配置实用程序(用 wpf 编写),以便他可以配置服务、从中读取数据等等。

是否有可能在一个应用程序中执行此操作?

预先感谢您的帮助!

i'm trying to create a windows service with C# in .net that runs before the user is logged on...
then when a user is logged on a symbol should appear in the system tray (next to the clock) to show the user that the service is running..
by double clicking that symbol a configuration utility (written in wpf) should be shown to the user, so he can configure the service, read data from it and so on ..

is there a possibility to do this within one application?

thanks in advance for any help!!!

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

洛阳烟雨空心柳 2024-09-17 08:17:53

不,您无法对一个应用程序执行此操作,因为服务在不同的会话中与不同的用户一起运行。您需要创建两个应用程序并在两者之间实现一些通信。

我不建议直接使用命名管道(例如 Kieren Johnstone 建议),但是看看 WCF,它是为进程间通信而设计的,并且很好地抽象了通信技术的实现细节。下面是一个可以帮助您使用 WCF 的链接: http:// www.switchonthecode.com/tutorials/wcf-tutorial-basic-interprocess-communication

最好的问候,
奥利弗·哈纳皮

No, you can't do this with one application as services run with a different user in a different session. You need to create two applications and implement some communication between both.

I would not recommend using named pipes directly (like Kieren Johnstone suggested), but to have a look at WCF which was designed for interprocess communication and nicely abstracts implementation details of the communication technology away from you. Here is a link that can propably help you with WCF: http://www.switchonthecode.com/tutorials/wcf-tutorial-basic-interprocess-communication.

Best Regards,
Oliver Hanappi

阳光的暖冬 2024-09-17 08:17:53

在一份申请中,没有。服务在会话0中运行,请参见此处:

http://www.microsoft.com/whdc/system/sysinternals /session0changes.mspx

您最好的选择是使用命名管道,请参见此处:

http://www.switchonthecode.com/tutorials /dotnet-35-adds-named-pipes-support

....或内存映射文件,请参见此处:

http://msdn.microsoft.com/en-us/library /dd997372.aspx

在more-.NETty的范围内,您还可以使用Remoting。您需要提供一些接口或协议来促进服务和管理实用程序之间的通信。管理进程启动/停止会更容易,您可以使用 ServiceController 类 (MSDN 参考)。

希望这会有所帮助(而且不会太令人沮丧)!

Within one application, no. Services run in session 0, please see here:

http://www.microsoft.com/whdc/system/sysinternals/session0changes.mspx

Your best bet is to used Named Pipes, see here:

http://www.switchonthecode.com/tutorials/dotnet-35-adds-named-pipes-support

....or a memory mapped file, see here:

http://msdn.microsoft.com/en-us/library/dd997372.aspx

Within the scope of more-.NETty, you could also use Remoting. You'll need to come up with some interface or protocol to facilitate communication between the service and the management utility. Managing the process start/stop would be easier and you could use the ServiceController class (MSDN ref).

Hope that helps (and itsn't too discouraging)!

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文