如何检测如果一个窗口的显示? [英] How to detect if a Window can be Shown?

查看:100
本文介绍了如何检测如果一个窗口的显示?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当应用程序正在运行为Windows服务(用.NET编写的),这将是检测用户是否登录,当用户登录时,才能够开始显示的最佳途径必要的对话,或者该用户已注销,因此对话的显示可以prevented?

When an application is running as a Windows Service (written in .NET), what would be the best way to detect whether or not a user is logged on, and when a user logs on, to be able to begin displaying the necessary dialogs, or when that user has logged off, so the display of dialogs can be prevented?

我希望我正确地表述的:)

I hope I phrased this correctly :)

推荐答案

您不应该从服务这样做的。首先,在默认情况下一个服务不具有访问桌面。您可以在Windows版本Vista的前勾选允许服务与桌面交互的属性服务对话框复选框改变这一点,但是这是一个非常,非常糟糕的主意。

You shouldn't be doing this at all from a service. First, a service by default doesn't have access to the desktop. You can change this in versions of Windows before Vista by checking the "Allow service to interact with desktop" checkbox on the properties dialog for the service, but this is a very, very bad idea.

在Vista中,服务无法与桌面上的所有交互。

In Vista, services cannot interact with the desktop at all.

正在使假设有仅会是机器上的一个交互式用户在当时,这并不总是如此。由于终端服务的,你可以有多个用户登录到互动环节。

You are making the assumption that there will only ever be one interactive user on the machine at the time, which is not always the case. Because of Terminal Services, you can have more than one user logged into interactive sessions.

你应该做的是创建一个启动时在用户登录。该计划将与该服务通过一些分布式技术进行交互的小客户端程序(如远程或WCF,我推荐后者)。基于接收到来自服务器的通信,该客户端程序可以启动对话框和用户界面元素,以与用户进行交互。

What you should do is create a small client program which is launched when the user logs in. This program would interact with the service through some distributed technology (like Remoting, or WCF, I recommend the latter). Based on the communication it receives from the server, that client program can launch dialogs and user interface elements to interact with the user.

这篇关于如何检测如果一个窗口的显示?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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