.Net (C#) 检测电视是否已连接
有人知道如何用 C# 检测电视当前是否连接到 PC 吗?
干杯
Anyone know how to detect if a television is currently connected to a PC in c#?
Cheers
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
设备是如何连接的?
每当发生设备到达/移除时,Windows 都会向系统中当前运行的所有应用程序发送一条名为 WM_DEVICECHANGE 的消息。 但要接收此消息,我们的应用程序应该处理“Windows Process 函数”。 C# 应用程序不会默认支持此功能,但可以添加它。 您可以扩展表单类。
对于 USB 大容量存储设备执行此操作的代码类似于:
它可能会让您了解如何实现它。
How is the device attached?
Whenever a device arrival/removal happens, Windows sends a message called WM_DEVICECHANGE to all the applications running currently in the system. But to receive this message our application should handle the "Windows Process function". C# applications will not have default support for this function, but it's possible to add it. You could extend the form class.
The code to do this for a usb mass storage device would be something like:
It might give you an idea how to implement it.
我想你在谈论显示器/电视?
您可以制作一个 winform 应用程序,其中有一个大按钮,当用户切换到电视时显示“TV CONNECTED”:-)
如果与 PC 的唯一连接只是 VGA 连接器,那么您就不走运了。 您始终可以实现连接到串行端口的红外传感器,以从遥控器读取红外信号(每当用户单击它时)。
I suppose you are talking about monitors/TV's ?
You can make a winform application with a big button saying 'TV CONNECTED' when the user switches to the TV :-)
If the only connection to the PC is just the VGA connector, you are out of luck. You could always implement an infrared sensor connected to a serial port to read infrared signals from the remote control (whenever the user clicks it).