WINMM sends the MODM_LONGDATA message to the modMessage function of a MIDI output driver when a client application wants the driver to make a data block available as output. This data block typically contains one or more MIDI events, including system-exclusive events. If the data block contains more than one MIDI event, the events are packed into the data block with no padding.

If a client of the MIDI output driver wants to send a single MIDI event, it is more efficient to use the MODM_DATA message.


DWORD modMessage(
   UINT      uDeviceID,
   UINT      uMsg,
   DWORD_PTR dwUser,
   DWORD_PTR dwParam1,
   DWORD_PTR dwParam2



Specifies the ID of the target device. Device IDs are sequential and have an initial value of zero and a final value that is equal to one less than the number of devices that the driver supports.


WINMM sets this parameter to MODM_LONGDATA when it calls modMessage to process this message.


Use this parameter to return instance data to the driver. Drivers that support multiple clients can use this instance data to track the client that is associated with the message.


This parameter specifies a far pointer to MIDIHDR data structure that identifies the data block.


This parameter specifies the size of the MIDIHDR structure.

Return value

The modMessage function returns MMSYSERR_NOERROR if the operation is successful. Otherwise, it returns one of the error messages in the following table.

Return codeDescription

The driver failed to load or initialize.


The specified data block has not been prepared.


The MIDI hardware is busy processing other data.



The driver must first check the MHDR_PREPARED bit in the dwFlags field of the MIDIHDR structure. If the bit is not set, the driver must return MIDIERR_UNPREPARED. The driver must also clear the MHDR_DONE bit, set the MHDR_INQUEUE bit, and place the data block in its output queue. Then the driver must return control to the client by returning MMSYSERR_NOERROR.

After the data block has been sent as an output, the driver must set the MHDR_DONE bit and clear the MHDR_INQUEUE bit before it notifies the client by using DriverCallback to send a MOM_DONE message.

The driver developer can design the driver to not return until the message has been sent to the output device. Alternatively, the driver can return immediately, but work in the background to send the MIDI data as output. The driver must maintain MIDI status across multiple MODM_DATA and MODM_LONGDATA calls.


Target platform


Available in Windows XP and later Windows operating systems.


Mmddk.h (include Mmddk.h, Mmsystem.h, or Windows.h)

See also




Send comments about this topic to Microsoft