I am trying to open cash drawer which is connected to Reciept printer
(Printer is connected to USB port of CPU).
We want to automatically detect the PORT for the selected printer. This
works fine using "GetPrinter" WinAPI (populating _PRINTER_INFO_2A
structure). And it displays USB002.
To open cash drawer we use "CreateFile" and "WriteFile" WIN APIs.
These functions work fine if PORT is of LPT/COM, but if its USB, it throws
invalid handle. To interact with USB, we need to send DevicePath.
Using SetupDiClassGuidsFromName, SetupDiGetClassDevs,
SetupDiEnumInterfaceDevice, SetupDiGetInterfaceDeviceDetail of
"SetupAPI.dll", we can enumerate available interface devices and can get
DevicePath.
But how do we map this strange DevicePath with Port name ?
For example,
For port USB002, how do I get respective DevicePath ?
Thanks in advance,