Tip:
Return the application when the buffer is full Program ;
The input buffer is only used for mutually exclusive messages;
Before the buffer is transmitted to midiinaddbuffer, call midiinprepareheader preparation and globalalloc to allocate memory to the tmidihdr and the buffer directed by lpdata (gmem_moveable and gmem_share are used) and use globallock to lock the buffer.
// Declaration: midiinaddbuffer (hmidiin: hmidiin; {input device handle} lpmidiinhdr: pmidihdr; {tmidihdr structure pointer} usize: uint {size of the tmidihdr structure}): mmresult; {0 is returned successfully; possible error values:} mmsyserr_invalhandle = 5; {the device handle is invalid} midierr_unprepared = 64; {No buffer prepared} // tmidihdr is the redefinition of the midihdr_tag structure: midihdr_tag = record lpdata: pchar; {pointer to the dedicated buffer} dwbufferlength: DWORD; {specify the 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 to the program} mhdr_prepared = $00000002; {buffer has been prepared for midiinprepareheader or midioutprepareheader} mhdr_inqueue = $00000004; {reserved (to the device)} mhdr_isstrm = $00000008; {stream buffer}
// example: