private void RefreshDevices(object sender, EventArgs e) { Log("Refreshing device list ..."); metroComboBoxInputDevice.Items.Clear(); // Close old port if (this.inputPort != null) { // Make sure port is closed and stopped if (this.inputPort.Started) { Log("Stopping previous port ..."); inputPort.Stop(); } if (this.inputPort.Opened) { Log("Closing previous port ..."); inputPort.Close(); } inputPort = null; } for (uint i = 0; i < InputPort.InputCount; i++) { MIDIINCAPS caps2 = new MIDIINCAPS(); InputPort.GetDeviceInfo(i, ref caps2, (uint)Marshal.SizeOf(typeof(MIDIINCAPS))); metroComboBoxInputDevice.Items.Add(caps2.szPname); } }
public static MMRESULT GetDeviceInfo(uint uDeviceID, ref MIDIINCAPS caps, uint cbMidiInCaps) => NativeMethods.midiInGetDevCaps(uDeviceID, ref caps, cbMidiInCaps);
internal static extern MMRESULT midiInGetDevCaps(uint uDeviceID, ref MIDIINCAPS caps, uint cbMidiInCaps);