且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

我怎么从windows service看到windows窗体。我可以吗?

更新时间:2023-12-06 14:09:16

Windows服务没有 UI,这是设计的。



如果你需要与正在运行的窗口进行通信为您提供实现机制和协议的服务,并让基于用户的流程获取并设置该协议的数据。
Windows Services have no UI, that is by design.

If you need to communicate with a running windows service you to implement a mechanism and protocol and have a user based process get and set data on that protocol.


您的服务正在一个无权访问的process \ session中运行桌面,因此它可以启动您的过程,但无法看到GUI。当没有人登录时服务也会运行,所以当没有人登录到盒子时会发生什么,你期望发生什么呢?



c# - 有没有办法从Windows 7上的Windows服务启动GUI应用程序? - 堆栈溢出 [ ^ ]
Your service is running under a process\session that doesn't have access to the desktop so it can launch your process but the GUI can't be seen. Services also run when no-one is logged in, so what happens when no-one is logged into the box, what do you expect to happen then?

c# - Is there any way to start a GUI application from a windows service on Windows 7? - Stack Overflow[^]