NO C FOR ME:
Very impressive initial attempt,...
A number of MIDI capable devices (especially those provided in commercial audio editing programs) are implemented as Direct Show plug-ins,...in older versions of DirectX. These are registered on your system as COM DLLs,...which means they can be enumerated by DirectX.
I know,...this concept sounds wrong,...I am referring not to audio hardware,...but, to software audio drivers (catagorized as DirectShow filters).
This accounts for the difference in enumerated MIDI devices returned from midiOutGetNumDevs,...and the actual number of MIDI capable devices that exist on your system. The vast majority of Direct Show filters are not audio devices,...and, it's a complete pain in the ass to enumerate them all,...and, then check their individual properties to locate the MIDI capable components.
In all honesty,...it's confusing as hell (especially if you are not familiar with COM activation).
Here are a number of MSDN references:
DirectShow FiltersThe Filter Graph and Its Components Alphabetical List of DirectShow Interfaces