Announcement
Collapse
No announcement yet.
Use CreateFile but need USB name
Collapse
X
-
You only need HID functions if you want to work with USB HID class devices, else it isn't needed...
-
-
Hi Cliff,
By commenting out the lpt select case statement in ListDevicesSerial() and changing Case "Port" to Case Else, my computer returned quite a list. I also changed the following in ShowDIALOG1Proc:
For i = LBound(DeviceSerial) To UBound(DeviceSerial) 'Get the status of each port
'PortInfo = PortInfo + DeviceSerial(i).Name + $Tab + StatusDevicesSerial(DeviceSerial(i).Name) + $CrLf
T1 = Trim$(DeviceSerial(i).Name, Any Chr$(0,10,13))
T2 = Trim$(StatusDevicesSerial(DeviceSerial(i).Name), Any Chr$(0,10,13))
If Len(T1) Then PortInfo = PortInfo + T1 + $Tab +T2 + $CrLf
Next i
Curiously it reports the old SONY CD-ROM CDU522 that died 2 years ago. I suspect this info is polling existing drivers not merely hardware.
Scott
========================================================
R Error: 2 The system cannot find the file specified. ---> Port Exists but is not connected to Windows
LPT1 Port Available
LPT1 Error: 5 Access is denied. ---> Port In Use by another program or driver
COM1 Port Available
COM4 Error: 2 The system cannot find the file specified. ---> Port Exists but is not connected to Windows
COM2 Error: 2 The system cannot find the file specified. ---> Port Exists but is not connected to Windows
LITE-ON CD-RW SOHR-5238 Error: 2 The system cannot find the file specified. ---> Port Exists but is not connected to Windows
SONY CD-ROM CDU522 Error: 2 The system cannot find the file specified. ---> Port Exists but is not connected to Windows
SONY CD-RW CRX220E Error: 2 The system cannot find the file specified. ---> Port Exists but is not connected to Windows
SONY CD-RW CRX220E Error: 2 The system cannot find the file specified. ---> Port Exists but is not connected to Windows
SONY CD-RW CRX220E Error: 2 The system cannot find the file specified. ---> Port Exists but is not connected to Windows
ST340014 Error: 2 The system cannot find the file specified. ---> Port Exists but is not connected to Windows
ST340014 Error: 2 The system cannot find the file specified. ---> Port Exists but is not connected to Windows
ST340014 Error: 2 The system cannot find the file specified. ---> Port Exists but is not connected to Windows
U.S. Robotics 56K Fax PC Error: 2 The system cannot find the file specified. ---> Port Exists but is not connected to Windows
IP Port Available
R Error: 2 The system cannot find the file specified. ---> Port Exists but is not connected to Windows
Visioneer 9320 Scanne Error: 2 The system cannot find the file specified. ---> Port Exists but is not connected to Windows
USB Flash Memory USB Devic Error: 2 The system cannot find the file specified. ---> Port Exists but is not connected to Windows
USB Flash Memory USB Devic Error: 2 The system cannot find the file specified. ---> Port Exists but is not connected to Windows
USB Flash Memory USB Devic Error: 2 The system cannot find the file specified. ---> Port Exists but is not connected to Windows
USB Flash Memory USB Devic Error: 2 The system cannot find the file specified. ---> Port Exists but is not connected to Windows
Generic STORAGE DEVICE USB Devic Error: 2 The system cannot find the file specified. ---> Port Exists but is not connected to Windows
HDS72251 2VLAT20 USB Devic Error: 2 The system cannot find the file specified. ---> Port Exists but is not connected to Windows
PNY Attache 2.0 USB Devic Error: 2 The system cannot find the file specified. ---> Port Exists but is not connected to Windows
SanDisk Cruzer Micro USB Devic Error: 2 The system cannot find the file specified. ---> Port Exists but is not connected to WindowsLast edited by Scott Hauser; 21 Dec 2007, 01:36 AM.
Leave a comment:
-
-
Use CreateFile but need USB name
I am not sure how to ask this one, but If I have code that can enumerate USB devices, I thought I would then do a "CreateFile" to check if the file was already in use or not.
Pierre Bellisle has the closest and best (YET AGAIN) example in the forums with Hardware enumeration using SetupApi.dll
Although his and many others use HID.dll at some point (not sure if it just because it works, or just because "You have to to in order to get the answer")
Sure I could use WMI, or some other way, but 1st I want to learn 1 concept at a time. (Although if I have to, SetupAPI and HID together is not out of the question if thats what I have to do)
It seems all the examples tend to follow the same pattern of
Code:[color=blue]HidD_GetHidGuid tHidGuid[/color] ' Init some items tIfcData.cbSize = SIZEOF(tIfcData) tIfcDetail.cbSize = 5 '<---If correct, sould be sizeof(tIfcDetail.cbSize) and not a hardcoded value
Sorry if I sound convoluted, but maybe Pierre, or Kev are watching (since most the code is blatantly "stolen" from them(and a few MSDN docs
) or a few others that may know about USB
All in all, my example I am working on would do the following:- List Devices known to Windows (whether currently attached or not), or list devices that at some point were attached
- Use CreateFile (unless there is a better way) to see if it is available, or already in use
- Excluding the mix of "USB adapters to --->Serial or Parallel, or some other format, I think as long as I know what I am trying to open, then I either get a succeed or fail"
in this case, it may be a concept that I have to try one then the other to determine, but hoping if all SetupApi.Inc then I can thin down my avenues a bitTags: None
Leave a comment: