To open a MIDI input device for recording, use the midiInOpen function. This function opens the device associated with the specified device identifier and returns a handle of the open device by writing the handle to a specified memory location.
If you use the MIDI_IO_STATUS flag with midiInOpen, the system uses the MIM_MOREDATA message to alert your application's callback function when it is not processing MIDI data fast enough to keep up with the input device driver. (The MM_MIM_MOREDATA message does the same job with window callbacks. However, for performance reasons, most applications will use callback functions instead of window callbacks.) If your application processes MIDI data in a separate thread, boosting the thread's priority can have a significant impact on the application's ability to keep up with the data flow.