midiInPrepareHeader

The midiInPrepareHeader function prepares a buffer for MIDI input.

MMRESULT midiInPrepareHeader(
  HMIDIIN hMidiIn,        
  LPMIDIHDR lpMidiInHdr,  
  UINT cbMidiInHdr        
);

Parameters

hMidiIn

Handle to the MIDI input device.

lpMidiInHdr

Pointer to a MIDIHDR structure that identifies the buffer to be prepared.

cbMidiInHdr

Size, in bytes, of the MIDIHDR structure.

Return Values

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

Value Description
MMSYSERR_INVALHANDLE The specified device handle is invalid.
MMSYSERR_INVALPARAM The specified address is invalid.
MMSYSERR_NOMEM The system is unable to allocate or lock memory.

Remarks

Preparing a header that has already been prepared has no effect, and the function returns zero.

After the header has been prepared, do not modify the buffer. To free the buffer, use the midiInUnprepareHeader function.

Before using this function, you must set the lpData, dwBufferLength, and dwFlags members of the MIDIHDR structure. The dwFlags member must be set to zero.

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, MIDIHDR, midiInUnprepareHeader