Windows Vista Session 0 和桌面之间如何通信?

发布于 2024-07-04 16:13:31 字数 220 浏览 4 评论 0原文

在 Vista 之前的 Windows 早期版本中,您可以让 Windows 服务与当前登录的桌面用户进行交互,以便轻松地从该服务在屏幕上显示信息。 在 Windows Vista 中,为了安全起见,添加了 Session 0,以将服务与桌面隔离。 在服务和会话 0 之外运行的应用程序之间进行通信的简单方法是什么? 到目前为止,我已经通过使用 TCP/IP 在两者之间进行通信来解决这个问题,但这似乎是一种草率的方法。

In prior versions of Windows before Vista you could have a Windows Service interact with the current logged in desktop user to easy display information on the screen from the service. In Windows Vista Session 0 was added for security to isolate the services from the desktop. What is an easy way to communicate between a service and an application running outside of Session 0? So far I have gotten around this by using TCP/IP to communicate between the two but it seems to be kind of a sloppy way to do it.

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

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

发布评论

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

评论(3

情愿 2024-07-11 16:13:32

您也可以使用共享内存或命名管道来促进 IPC。 从概念上讲,这类似于 TCP/IP,但您不必担心找到未使用的端口。

您必须确保您创建的命名对象以“Global\”为前缀,以允许所有会话访问它们,如所述 此处

据我所知,服务无法再直接与桌面交互。

You can use shared memory or named pipe to facilitate IPC as well. Conceptually this is similar to TCP/IP, but you don't have to worry about finding an unused port.

You have to make sure that the named objects you create are prefixed with "Global\" to allow them to be accessed by all sessions as described here.

AFAIK there is no way for a service to directly interact with the desktop any more.

粉红×色少女 2024-07-11 16:13:32

事实上,出于安全原因,不再可能直接与“桌面”通信。 当您生活在具有多个活动用户+远程会话的计算机中时,“桌面”到底是什么?

解决该问题的一般方法是使用通过某种 RPC 机制(TCP/IP、IPC、其中之一的 .Net 远程处理通道等)进行通信的服务应用程序。 这有点痛苦,但我认为改变的好处是值得的。

Indeed, for security reasons it is no longer possible to communicate directly with the "desktop". What exactly is the "desktop" anyway, when you live in a machine with multiple active users + remote sessions?

The general way to solve the problem is to use service apps which communicate via some RPC mechanism (TCP/IP, IPC, .Net Remoting Channels over one of those, etc). Its kind of a pain, but I think the benefits are worth the change.

恰似旧人归 2024-07-11 16:13:32

对于与桌面对话的服务,您几乎只能使用其中一种 RPC 机制。 .NET 远程处理机制 (IpcServerChannel< /a>) 为此目的实现并不难。

此外,通过 .NET,桌面应用程序可以使用 ServiceController.ExecuteCommand。 服务通过 ServiceBase.OnCustomCommand< 接收这些命令/a>. 这更容易做到,如果控制服务是您唯一的要求,这将是您所需要的。

For the service to talk to the desktop, you're pretty much stuck with one of the RPC mechanisms. The .NET remoting mechanism (IpcServerChannel) isn't to hard to implement for this purpose.

Also with .NET a desktop application can send messages directly to the service with the ServiceController.ExecuteCommand. These commands are received by the service via ServiceBase.OnCustomCommand. This is even easier to do, and would be all you need if controlling the service is your only requirement.

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