midiConnect

The midiConnect function connects a MIDI input device to a MIDI thru or output device, or connects a MIDI thru device to a MIDI output device.

MMRESULT midiConnect(
  HMIDI hMidi,      
  HMIDIOUT hmo,     
  LPVOID pReserved  
);

Parameters

hMidi

Handle to a MIDI input device or a MIDI thru device. (For thru devices, this handle must have been returned by a call to the midiOutOpen function.)

hmo

Handle to the MIDI output or thru device.

pReserved

Reserved; must be NULL.

Return Values

Returns MMSYSERR_NOERROR if successful or an error otherwise. Possible error values include the following.

Value Description
MIDIERR_NOTREADY Specified input device is already connected to an output device.
MMSYSERR_INVALHANDLE Specified device handle is invalid.

Remarks

After calling this function, the MIDI input device receives event data in an MIM_DATA message whenever a message with the same event data is sent to the output device driver.

A thru driver is a special form of MIDI output driver. The system will allow only one MIDI output device to be connected to a MIDI input device, but multiple MIDI output devices can be connected to a MIDI thru device. Whenever the given MIDI input device receives event data in an MIM_DATA message, a message with the same event data is sent to the given output device driver (or through the thru driver to the output drivers).

Requirements

  Windows NT/2000/XP: Included in Windows NT 3.1 and later.
  Windows 95/98/Me: Included in Windows 95 and later.
  Header: Declared in Mmsystem.h; include Windows.h.
  Library: Use Winmm.lib.

See Also

Musical Instrument Digital Interface (MIDI), MIDI Functions, midiOutOpen, MIM_DATA

Show: