如何在WinCE6.0 .NET 3.5设备上检测/识别USB设备 [英] How to detect / identify USB devices on a WinCE6.0 .NET 3.5 Device

查看:134
本文介绍了如何在WinCE6.0 .NET 3.5设备上检测/识别USB设备的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

首先 - 我是论坛的新手,也是WinCE开发的新手,所以请不要错过任何明显的内容,例如在哪里发布此问题或要包含哪些信息。这就是说:

Firstly - I am new to the forums and fairly new to WinCE development so apologies for missing anything obvious like where to post this question or what information to include. That said here goes:

我遇到了与识别USB设备连接位置有关的WinCE6.0应用程序(.NET Compact Framework 3.5)的问题。我的问题源于此:

I have an issue with a WinCE6.0 application (.NET Compact Framework 3.5) relating to identifying what USB devices are connected where. My problem originates from this:

当您打开我们的设备(它是嵌入式PC - AxiomTek的GOT-3571T)并且任何USB端口都没有USB Key时,文件系统设置为在我的设备下,在其他目录中有一个条目:\ Hard Disk。如果您随后插入USB密钥,我们
可以捕获插入消息和设备,使用大容量存储设备,弹出为\Hard Disk2

When you power up our unit (it's a embedded PC - GOT-3571T from AxiomTek) with no USB Key in any USB port, the filesystem is setup such that under My Device, amongst other directories there is an entry: \Hard Disk. If you subsequently plug in a USB key we can trap the insert message and device, meing a Mass storage device, pops up as \Hard Disk2

如果您打开电源有USB键的单元,没有插入消息(可以理解)但是关键的是,USB Key现在是\ Hard磁盘而主要的'驱动器'是\硬盘2。

If you power up the unit with the USB Key in, there are no insert messages (understandably) but critically, the USB Key is now \Hard Disk and the main 'drive' is \Hard Disk2.

这给我带来了一个问题,因为我需要专门询问USB Key以确定一些外出应用程序的系统设置。所以解决这个问题的'简单'方法是查询\ Hard磁盘和
\硬盘2的FS /驱动器安装信息,并尝试确定一些有关物理介质的信息,如果可以的话发现一个是RAM,一个是USB,例如我将被分类。

This presents me with a problem because I need to interrogate the USB Key specifically to determine some system settings for out application. So my 'simple' approach to solving this was to interrogate the FS / drive mounting information for \Hard Disk and \Hard Disk 2 and try to ascertain some information as to what the physical media was, if I could find that one was RAM and one was USB for example I would be sorted.

我没有找到任何有用的东西。遗憾的是,DirectoryInfo和FileSystemInfo类似乎没有提供API来发现底层媒体。

I haven't found anything that would help. Sadly DirectoryInfo and FileSystemInfo classes do not appear to provide APIs to discover the underlying media.

为了从不同的角度来看,我想知道我是否可以查询USB子系统来发现什么类型的设备已连接,然后随后发现任何大容量存储设备的安装/枚举方式,因此发现USB Key是
,称为\ Hard Disk2,但.NET CF 3.5不支持WMI(ManagementClass)找不到另一种方式。

To approach this from a different angle, I wondered whether I could query the USB subsystem to discover what type of devices are connected and then subsequently discover how any Mass storage devices are mounted / enumerated, thus discovering a USB Key was called \Hard Disk2, but the WMI (ManagementClass) is not supported under .NET CF 3.5 and I haven't found another way.

进一步的移动,广泛搜索网页显示很多人都有USB插入和移除问题,这在我的系统上不是问题,但是nobady似乎有点击这个Meda命名/文件系统/大容量存储装置问题。

Further move, extensive searching of the web shows lots of people have issues with USB insert and removal, which is not a problem on my system but nobady appears to have hit this Meda naming / file system / mass storage mounting issue.

如果有人有任何想法,我会非常感激...

If anyone has any ideas, I would be very greatful...

干杯

Jonathan

推荐答案

最简单的方法是更改​​USB Mass Storage的注册表,以便&&吨;文件夹"设置是别的,然后"硬盘":

The easiest way is to change the registry for USB Mass Storage so that the "Folder" setting is something else then "Hard Disk":

[HKEY_LOCAL_MACHINE \System\StorageManager \Profiles\USBHDProfile]

    "名称"="USB硬盘驱动器"

    " Folder" =" USB Disk" ;更改为"硬盘"

[HKEY_LOCAL_MACHINE\System\StorageManager\Profiles\USBHDProfile]
    "Name"="USB Hard Disk Drive"
    "Folder"="USB Disk" ; Changed from "Hard Disk"

现在插入的任何USB驱动器都将安装为"USB Disk"。 (以及随后的驱动器为"USB Disk2"等)。

Now any USB drive inserted will mount as "USB Disk" (and subsequent drives as "USB Disk2" etc).

另一种更复杂的方法是更改​​USB堆栈,以便根据端口号创建名称。我之前已经为那些需要为连接到某个端口的设备命名的客户做了这个。该名称将变为
,例如"USB Disk 4-2-2",这意味着它已连接到端口4->集线器端口2->集线器端口2.

The other, more elaborate, way is to change the USB stack so that it will create a name based on the port number. I've done that in the past for a customer that needed to have consequent naming for devices connected to a certain port. The name would become something like "USB Disk 4-2-2", meaning it was connected on port 4->hub port 2->hub port 2.

第一个解决方案在您的情况下可能会正常工作。

The first solution will probably work fine in your case.

遗憾的是,没有现成的解决方案来获取底层媒体,但没有什么能阻止您添加自定义功能进入USB堆栈,可以从中获取更多信息。

There is unfortunately no out-of-the-box solution to get the underlying media, but nothing stops you from adding custom functionality to the USB stack that will allow you to get more information from it.


这篇关于如何在WinCE6.0 .NET 3.5设备上检测/识别USB设备的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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