midiInGetDevCaps (winmm)
Last changed: -70.166.33.5

.
Summary
The midiInGetDevCaps function determines the capabilities of a specified MIDI input device.

C# Signature:

    [DllImport("winmm.dll", SetLastError = true)]
    private static extern MMRESULT midiInGetDevCaps(UIntPtr uDeviceID, ref MIDIINCAPS caps, uint cbMidiInCaps);

User-Defined Types:

MIDIINCAPS

MMRESULT

Alternative Managed API:

Do you know one? Please contribute it!

Notes:

Tips & Tricks:

Use (uint)Marshal.SizeOf(typeof(MIDIINCAPS)) for cbMidiInCaps.

Sample Code:

        public void GetInputDevices()
        {
        uint inDevs = midiInGetNumDevs();
        if (inDevs > 0)
        {
            for (int x = 0; x < inDevs; x++)
            {
            MIDIINCAPS caps = new MIDIINCAPS();
            midiInGetDevCaps((UIntPtr)x, ref caps, (uint)Marshal.SizeOf(typeof(MIDIINCAPS)));

            //Do whatever you want with the caps object here
            MessageBox.Show(caps.szPname);
            }
            return;
        }
        MessageBox.Show("No MIDI Input Devices Detected");
        }
    }

Documentation