My c# application must use multiple identical USB MIDI interfaces which are all from the same manufacturer.
In device manager, all devices appear with the same driver name / CLSID - only the PNPDeviceID is different. When I list all MIDI inputs / outputs (using MIDI-dot-net), they appear as follows:
- ACME-MIDI: Port 1
- 1- ACME-MIDI: Port 1
- 2- ACME-MIDI: Port 1
Unfortunately, those names are not always the same for the same device. The ports of device 1 appear sometimes as "ACME-MIDI: Port 1" and sometimes as "1-ACME: Port 1" (they change e.g. after a reboot).
I have used different ways trying to find what name belongs to what device (SetupDi, WMI, Win32_PnPSignedDriver, ...) but I either get the device ID OR the port names it reports, but I'm unable to find the reported MIDI port name (ACME-MIDI: Port n) using the device id or driver key.
Any suggestions?
Update
I'm still looking for a solution to list the Input / Output ports of a MIDI USB interface on a given port (e.g. using Windows API). Seems like this is quite tricky, that's why I start a bounty on this.
Unfortunately, when using the MIDI APIs alone there is no way to differentiate the devices. You must rely on their name. Fortunately, while the devices order can change, it's my experience that this doesn't typically happen on reboot. However, as you have seen, it can.
I've handled this in the past in my own software by prompting the user to press a key or move a control knob on a device to differentiate them.
来源:https://stackoverflow.com/questions/27173703/how-to-deal-with-multiple-identical-midi-usb-devices