I have two instances of a given device on a given machine (actually they are different devices but they use the same driver). I need to know which of these two instances I am talking to.

The problem seems to boil down to mapping an open device handle (or name, e.g. \\DosDevices\MyDevice-0) to the unique device ID(e.g. PCI\VEN_xxxx&DEV_yyyy&SUBSYS_nnnnnnn&REV_B5\3&11583659&0&E2). Notice that the uniqueness of the ID is in the tail, in this case, '3&11583659&0&E2'.

The handle is obtained from a call to CreateFile(sName, .... ).

The device ID is coming in through a call to CM_Get_Device_ID_Ex(), which in turn uses a descriptor returned by SetupDiEnumDeviceInfo(), which in turn uses a handle returned by SetupDiGetClassDevsEx(), none of which uses a device name or returns a handle of the type returned by CreateFile().

So, I can:
- Use the handle to get the unique ID for that device, then match on the ID from the SetupDi*() and CM_*() functions ... but how to get the ID using the handle?
- Get the name of the device using the SetupDi*() or CM*(), so I can get a handle from CreateFile() ... but how to get the name?

Any other way to do this?

Thanks gobs