midiInPrepareHeader function

The midiInPrepareHeader function prepares a buffer for MIDI input.

Syntax

MMRESULT midiInPrepareHeader(
  HMIDIIN   hmi,
  LPMIDIHDR pmh,
  UINT      cbmh
);

Parameters

hmi

Handle to the MIDI input device. To get the device handle, call midiInOpen.

pmh

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

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

cbmh

Size, in bytes, of the MIDIHDR structure.

Return Value

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

Return code 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

Before you pass a MIDI data block to a device driver, you must prepare the buffer by passing it to the midiInPrepareHeader function. After the header has been prepared, do not modify the buffer. After the driver is done using the buffer, call the midiInUnprepareHeader function.

The application can re-use the same buffer, or allocate multiple buffers and call midiInPrepareHeader for each buffer. If you re-use the same buffer, it is not necessary to prepare the buffer each time. You can call midiInPrepareHeader once at the beginning and then call midiInUnprepareHeader once at the end.

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

Requirements

   
Minimum supported client Windows 2000 Professional [desktop apps only]
Minimum supported server Windows 2000 Server [desktop apps only]
Target Platform Windows
Header mmeapi.h (include Windows.h)
Library Winmm.lib
DLL Winmm.dll

See Also

Allocating and Preparing MIDI Data Blocks

MIDI Functions

midiInUnprepareHeader