检测 USB 连接 -- C# .Net CF 3.5
我有一个在 Windows Mobile 6.1 设备上运行的应用程序 (.Net Compact Framework 3.5),我想检测 USB 连接何时发生变化(连接或断开连接)。
我最初使用 SystemProperty.CradlePresent 属性来触发事件,但我想知道这是否仅在连接的设备具有 ActiveSync 时才有效?我将通过 USB 从未运行 ActiveSync 的 Linux 设备接收连接。
我仍然可以使用 SystemProperty.CradlePresent
检测 USB 连接/断开连接吗?或者我是否需要探索其他选项来检测 USB 事件?谢谢。
I have an application (.Net Compact Framework 3.5) running on a Windows Mobile 6.1 device and I want to detect when the USB connection changes (either something connects or disconnects).
I was originally using the SystemProperty.CradlePresent
property to trigger an event but I am wondering if this only works if the device connecting has ActiveSync? I will be receiving a connection via USB from a Linux device that does not have ActiveSync running on it.
Can I still use SystemProperty.CradlePresent
to detect the connect/disconnect from the USB? Or do I need to explore other options to detect the USB event? Thanks.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
也许我之前的问题可能会有所帮助:
如何检测 USB 断开事件? (Windows,.NET C# 应用程序)
我最终监听并处理了
WM_DEVICECHANGE
事件。它们在此处指定:http://msdn.microsoft。 com/en-us/library/aa363480(VS.85).aspx不幸的是,我不再有源代码的副本,所以我对它的记忆有点模糊。我不知道这个解决方案是否适用于您的情况。
Perhaps this previous question of mine may help:
How can I detect a USB disconnect event? (Windows, .NET C# application)
I ended up listening for and handling
WM_DEVICECHANGE
events. They are specified here: http://msdn.microsoft.com/en-us/library/aa363480(VS.85).aspxUnfortunately I don't have a copy of the source code anymore so my memory on it is a bit hazy. I don't know if this solution applies in your context.
检查这个,您也许能够获取部分源代码。它是用 C# 编写的,带有 GUI。请记住,每次运行检查新 USB 驱动器的程序时,它都会占用内存和 CPU,因此您可能需要降低检查的时间间隔,然后为不耐烦的用户提供“刷新”按钮。
Check this out, you might be able to grab part of the source code. Its written in C# with a GUI. Keep in mind every time you have a program running that is checking for new USB drives, it will take up memory and CPU so you might want to tone down the intervals at which it checks and then supply a "refresh" button for impatient users.