Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Cannot open a USB Device using CreateFile

5,186 views
Skip to first unread message

Neil Strong

unread,
Oct 21, 2002, 6:26:58 AM10/21/02
to
I've obtained the device name of a USB Mass Storage Device ( A Compact Flash
card in a USB reader ) using SetupDiGetRegistryProperty
SPDRP_PHYSICAL_DEVICE_OBJECT_NAME ), which returns "\Device\USBPDO-1",
however when I pass this to CreateFile() I get a file does not exist error.

I'm using SetupDiGetRegistryProperty because
SetupDiGetDeviceInterfaceDetail() always seems to return no interfaces.

Can someone point me at some code/documentation showing how one of these
mass storage devices can be opened directly please.

Regards,
Neil


Tim Robinson

unread,
Oct 22, 2002, 4:47:09 PM10/22/02
to
Neil Strong <Neil....@XYX.xom> wrote:
| I've obtained the device name of a USB Mass Storage Device ( A
| Compact Flash card in a USB reader ) using SetupDiGetRegistryProperty
| SPDRP_PHYSICAL_DEVICE_OBJECT_NAME ), which returns "\Device\USBPDO-
| 1", however when I pass this to CreateFile() I get a file does not
| exist error.
|
| I'm using SetupDiGetRegistryProperty because
| SetupDiGetDeviceInterfaceDetail() always seems to return no
| interfaces.

Names of the form \Device\xxx are internal NT object manager names which are
inaccessible to Win32. You will only be able to access your device if it
creates a symbolic link to \Device\USBPDO-1 from the \??\ directory. Objects
in the \??\ kernel directory show up through \\.\ in Win32. Use Winobj in
the DDK (or download it from www.sysinternals.com) to check.

--
Tim Robinson, MVP (Windows SDK)
http://www.themobius.co.uk/


Neil Strong

unread,
Oct 23, 2002, 5:01:23 AM10/23/02
to
Tim,

Thanks for the response.

I've found the device I want listed under
\\?\USBSTOR#Disk&Ven_Generic&Prod_STORAGE_DEVICE&Rev_0.01#{ guid }

I can open this with CreateFile() and read the data.

My problem is that I don't know HOW to do this programatically - I want to
enumerate, identify the new USB Mass Storage device and open it, preferably
without the user having to rummage through the registry for the device name
and type it in :-)

Can you suggest a way to get access to this device name? The documentation
says I should be able to do this with SetupDiGetDeviceInterfaceDetail(), but
I'm not having much luck here - I've been told it only works for HID
devices.

Many Thanks

Regards,
Neil


"Tim Robinson" <tim_at_gaat.f...@nowhere.com> wrote in message
news:ap4d9p$rat2p$1...@ID-103400.news.dfncis.de...

rowan....@gmail.com

unread,
May 12, 2016, 12:59:40 PM5/12/16
to
I have a similar problem (yes, I know it's 14 years later...).

I am trying to write a C program to communicate with some OneWire devices from a Windows PC via a Maxim DS9490R USB-to-OneWire bridge. The C program (a simple command line application) is built using Visual Studio C++. I am having trouble with the CreateFile() function. What string do I have to supply as the "filename" parameter to identify the DS9490R, which is plugged into a USB port on my PC? The code that I am basing my program on (part of Maxim's OneWire Public Domain API) contains the comment "For this platform use format '\\.\DS2490-X' where X is the port number". DS2490 is the name of the chip inside the DS9490R. I have tried the format given, and many variations of it, and all give me an error "Error 23: Failed to acquire a necessary system resource". I know that the hardware is working, because a different Maxim application (OneWireViewer, a Java app) works perfectly well, and finds the DS9490R, and the devices attached to the OneWire network, and can read values back from them. I just need to make this work in my C program.

I have tried using WinObj, which shows thousands of entries, some with Symlinks, all showing things like \Device\USBPDO-13, but nothing like \\.\smething. And none of them obviously corresponding to my DS9490R. This, I'm afraid, does not help me at all.

I hope someone can give me a hint that can get me over this hurdle.

Thanks - Rowan
0 new messages