Getting friendly name from Windows NT device path - windows-7

Let's say that I have already determined the following device path for a certain bridge device:
\Device\USBSER000
How would I be able to programatically look up its device entry in the registry, i.e.,
HKLM\SYSTEM\CurrentControlSet\Enum\USB\Vid_xxxx&Pid_xxxx\xxxxxxxxxx
Thanks in advance.

Related

Is there any way Not to detect USB from windows PC?

Is there any way Not to detect USB from windows PC?
The USB device should not mount on windows PC ,It should be handled by my application..
Suggestions please...
As far as I know there is no way of stopping the mount on the windows PC, however, you could set it up to autorun so that when it is plugged it in attempts to launch your application. This answer has some information on how to do this: https://stackoverflow.com/a/255067
There is also the option to hide a drive in windows by removing is drive letter (http://www.howtogeek.com/97203/how-to-hide-a-drive-in-windows-so-that-no-one-will-know-its-there/) however, this is almost certainly going to stop your application from reading it too.
If this is for a specific security reason then perhaps you could look at encrypting the drive and allowing only the application to decrypt the data. Thus, whilst mounted in windows it will be of little use.
Sorry I couldn't be of much more help.
Microsoft provides a utility called devcon for free download.
It's a "Command Line Uility Alternative to Device Manager".
It can actually do many things that I won't get into here, but removing a plug & play device is a simple operation once you know the unique name of the device you want to manipulate.
Refer this to check how to work with it.
It sounds like you don't want your device to show up as a drive in My Computer. In that case, why are you using the Mass Storage Device class at all? You could make a custom, vendor-specific device and talk to it using control/interrupt/bulk transfers with WinUSB. You would need to change the Device's USB descriptors to indicate it is a vendor-specific device and not a mass-storage device.

Opening an FTDI device based on bus location ID

I have a few FTDI devices connected to my Mac. They all have the same description, PID, and VID. I want to be able to specify to FT_OpenEx() which one I want to open.
I can use the IO Kit APIs to get the bus location ID of the device I'm interested. The FT_OpenEX() API allows me to pass in a location instead of a description or serial number.
However, the FT APIs that return location IDs return values that look nothing like bus location IDs. One of the devices I have connected has a bus location ID of 0x1a127000, bus when I use the FT APIs to get the locations of all devices, it will say things like 0x1a051 and 0x1a052.
Is there any way to convert from IO Kit bus location ID and the FT location, or otherwise specify which device to use?
I recently had a similar problem: on some locations and devices I got 0 as location id. I wrote a request for assistance to FTDI and this is what I got:
We tested a USB 3.0 host PCI card found it not compatible with our
drivers for the following reason.
Existing host ports on a Windows machine are given a name in the
format: \device\usbfdo-# where # is a number.
The USB 3.0 card is known as a \device\device# where # is a number.
The USB 3.0 host port does not follow the standard naming convention
on a windows machine we do not attempt to open this port to send
device ID to when enumerating and trying to load drivers.
As we expect Microsoft to follow convention when they add support for
3.0, we expect the problem to go away from our point of view. As such we are still of the opinion the problem lies with the 3.0 host and not
our drivers.
Even if it was possible to make changes to support this host
controller it is highly probable that the next host device you try
(different manufacturer) will have another variant requiring a
different modification. This would not be a sustainable model and goes
against the PnP ethos of USB.
We believe this issue has been resolved in Windows 8. We are currently
working on the certification of our new windows 8 driver, I expect
this to be available by the end of February.
This is not very satisfying but at least it describes why it is not working. When I have time I will try to get the location id by using libusbX and then opening it with the FTDI API routines.
Not sure when that will be, though...
Veit
Since I already did this for linux once and have a working solution, I thought I'd try to figure it out for the mac as well.
I am not sure if I did this correctly but here's what I came up with:
Basically, you take the MacOSX location id right shift 16 bits, binary & with 0xff00 and add the device address.
That should be equal to the location ID you get from the ftdi driver.
Example:
In the "System Information" program I can find my USB device and see something like this:
Location ID: 0x14100000 / 21
That seems to be the "location id / device number".
Now plug it into that formula:
0x141000000>>16 = 0x1410
0x1410&0xff00 = 0x1400
0x1400|21 = 0x1415
So in decimal notation the location id is: 5141 which matches what FTDI returned. Note that 21 used above is 0x15 in hex.
I just figured this out 30 minutes ago so if there are problems with this implementation let me know. I need this to work reliably as well. I tried putting a hub between the mac and the device and the formula still applies.
The IOKit calls are:
kr = (*dev)->GetLocationID(dev, &locationid);
kr = (*dev)->GetDeviceAddress(dev, &address);
described at the apple developer reference website.
EDIT
since you have 5 digits in your FTDI location id, I would be interested in what your device device number is. Maybe my method doesn't hold up under your circumstances?

Windows device name

I'm trying to get a device name for a USB Bluetooth transceiver to use with CreateFile, but I don't know the file path. I've tried the USB file path but always return SHARING_VIOLATION.
In order to understand if that's the correct device path, how can I get Windows registered device names? Is there a standard device path for a Bluetooth transceiver?
The most straight-forward is likely USBDeview to find the exact device name.
And I'm not aware of a standard name for the BT transceiver.

Programmatically Find Out Type of Mounted Drive - Mac OSX

It doesn't seem that DiskArbitration framework provides a way to find out the device type (network drive, external drives, etc). Is there any other way to programmatically figure out the type of a mounted device?
Get a CFDictonary from DADiskCopyDescription, kDADiskDescriptionVolumeKindKey key gives a reasonable idea of the type

How should I get ActiveSync / Mobile Dev Center to recognise my Windows CE device via USB?

We develop a custom Windows CE-based device. To connect this to the PC via ActiveSync / Mobile Device Center, we have to set up entries so that the WCE USB Serial Host (wceusbsh.sys) recognises our Vendor ID (Vid) and Product ID (Pid).
To do this, to date, we have distributed a modified version of wceusbsh.inf and wceusbsh.sys: when the user first connects the device then ActiveSync basically says it does not recognise the device, and the user is asked to identify a driver for it. If they now point at the location where they've stored our wceusbsh.* files then all is well. However this is pretty clunky.
What we really want is a slick way to do this, preferably by running an installer which just gets everything ready, so that as soon as the device is plugged in it is recognised by wceusbsh.sys.
Any clues how to do this? There seem to be a ton of registry entries which relate to WCEUSBSH, and it's not clear how these are set: just "installing" the .INF file doesn't seem to allow for setting them all, so it does look like ActiveSync reads the .INF file and then adds some more information before appending the new info to the Registry.
Thanks
Well, in case anyone else comes looking for an answer to this, we managed to do it via this link from MSDN WinUSB (Windows Driver Kit). We now have a driver install program which sets up USB / Mobile Device Center so that when you plug in the CE device it is recognised correctly.

Resources