WPF识别远程访问(不是Winforms)
WPF 应用程序如何知道它是否正在远程操作(通过 VNC 或远程桌面)?
在 winforms 中,有 System.Windows.Forms.SystemInformation.TerminalServerSession 根据 检测远程桌面连接,但是WPF 中有一个简单的方法吗?
我想现在的黑客可能是在 WPF 上拥有一个不可见的 Winforms 主机,并使用它自己的能力来托管可以识别相同内容的虚拟 win 表单...但这对我来说看起来很蹩脚!
任何意见将不胜感激!
谢谢
How can a WPF app know if its getting remotely operated (via VNC or remote desktop)?
In winforms there is System.Windows.Forms.SystemInformation.TerminalServerSession as per Detecting remote desktop connection but is there a strightforward way for this in WPF?
I guess the hack for now could be to have an invisible Winforms host on WPF and use its own capacity to host dummy win form that can identify the same... but that looks lame to me!
Any inputs would be appreciated!
Thx
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
您不需要不可见的 WinForms 主机...您只需添加对 System.Windows.Forms 程序集的引用,并使用 SystemInformation.TerminalServerSession 静态属性即可。
如果您不想依赖 WinForms,可以使用
GetSystemMetrics
Win32 API:You don't need an invisible WinForms host... you can just add a reference to the
System.Windows.Forms
assembly, and use theSystemInformation.TerminalServerSession
static property.If you don't want a dependency on WinForms, you can use the
GetSystemMetrics
Win32 API:此方法不需要 Windows 窗体窗口,只需要对 DLL 的引用。
如果不想引用this,可以自己调用该方法来检查this,实现如下(我将其包装在一个类中):
This method does not require a Windows Forms Window, only a reference to the DLL.
If you don't want to reference this, you can call the method to check this yourself, the implementation is as follows (I've wrapped it in a class):