Tip:
Before the buffer is sent to midioutlongmsg, call midioutprepareheader preparation and globalalloc to allocate memory to tmidihdr and the buffer to which lpdata points (gmem_moveable and gmem_share are used) and use globallock to lock the buffer.
// Declaration: midioutlongmsg (hmidiout: hmidiout; {Device handle} lpmidiouthdr: pmidihdr; {tmidihdr structure pointer} usize: uint {tmidihdr structure size}): mmresult; {0 is returned successfully; for possible error values, see:} mmsyserr_invalhandle = 5; {the device handle is invalid} midierr_unprepared = 64; {the buffer tmidihdr is not ready} midierr_notready = 67; {Device Busy with other data} // tmidihdr is the redefinition of the midihdr_tag structure: midihdr_tag = record lpdata: pchar; {dedicated buffer pointer} dwbufferlength: DWORD; {specified buffer length} dwbytesrecorded: DWORD; {specify the data volume in the buffer during input} dwuser: DWORD; {specify user data} dwflags: DWORD; {specify the buffer information flag} lpnext: pmidihdr; {reserved (to device)} Reserved: DWORD; {reserved (to device)} dwoffset: DWORD; {buffer offset at callback start} dwreserved: array [0 .. 7] of DWORD; {reserved (to the system)} end; // optional value of dwflags: mhdr_done = $00000001; {the device has returned the buffer. Program } Mhdr_prepared = $00000002; {a buffer has been prepared for midiinprepareheader or midioutprepareheader} mhdr_inqueue = $00000004; {reserved (to the device)} mhdr_isstrm = $00000008; {stream buffer}
// Example: