The midiDisconnect function disconnects a MIDI input device from a MIDI thru or output device, or disconnects a MIDI thru device from a MIDI output device.
MMRESULT midiDisconnect(
  HMIDI hMidi,      
  HMIDIOUT hmo,     
  LPVOID pReserved  
);
 
Returns MMSYSERR_NOERROR if successful or an error otherwise. Possible error values include the following:
| Value | Description | 
|---|---|
| MMSYSERR_INVALHANDLE | Specified device handle is invalid. | 
MIDI input, output, and thru devices can be connected by using the midiConnect function. Thereafter, whenever the MIDI input device receives event data in an MIM_DATA message, a message with the same event data is sent to the output device driver (or through the thru driver to the output drivers).
  Windows NT: Requires version 3.1 or later.
  Windows: Requires Windows 95 or later.
  Windows CE: Unsupported.
  Header: Declared in mmsystem.h.
  Import Library: Use winmm.lib.
Musical Instrument Digital Interface (MIDI) Overview, MIDI Functions, midiConnect, MIM_DATA