The midiInUnprepareHeader function cleans up the preparation performed by the midiInPrepareHeader function.

MMRESULT midiInUnprepareHeader(
  HMIDIIN hMidiIn,        
  LPMIDIHDR lpMidiInHdr,  
  UINT cbMidiInHdr        



Handle to the MIDI input device.


Pointer to a MIDIHDR structure identifying the buffer to be cleaned up.


Size of the MIDIHDR structure.

Return Values

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

Value Description
MIDIERR_STILLPLAYING The buffer pointed to by lpMidiInHdr is still in the queue.
MMSYSERR_INVALPARAM The specified pointer or structure is invalid.
MMSYSERR_INVALHANDLE The specified device handle is invalid.


This function is complementary to midiInPrepareHeader. You must use this function before freeing the buffer. After passing a buffer to the device driver by using the midiInAddBuffer function, you must wait until the driver is finished with the buffer before using midiInUnprepareHeader. Unpreparing a buffer that has not been prepared has no effect, and the function returns MMSYSERR_NOERROR.


**  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, midiInPrepareHeader, MIDIHDR, midiInAddBuffer