WORD midiInOpen(lphMidiIn, wDeviceID, dwCallback, dwCallbackInstance, dwFlags)
This function opens a specified MIDI input device.
LPHMIDIIN lphMidiIn
Specifies a far pointer to an HMIDIIN handle. This location is filled with a handle identifying the opened MIDI input device. Use the handle to identify the device when calling other MIDI input functions.
WORD wDeviceID
Identifies the MIDI input device to be opened.
DWORD dwCallback
Specifies the address of a fixed callback function or a handle to a window called with information about incoming MIDI messages.
DWORD dwCallbackInstance
Specifies user instance data passed to the callback function. This parameter is not used with window callbacks.
DWORD dwFlags
Specifies a callback flag for opening the device.
CALLBACK_WINDOW
If this flag is specified, dwCallback is assumed to be a window handle.
CALLBACK_FUNCTION
If this flag is specified, dwCallback is assumed to be a callback procedure address.
Returns zero if the function was successful. Otherwise, it returns an error number. Possible error returns are:
MMSYSERR_BADDEVICEID
Specified device ID is out of range.
MMSYSERR_ALLOCATED
Specified resource is already allocated.
MMSYSERR_NOMEM
Unable to allocate or lock memory.
Use midiInGetNumDevs to determine the number of MIDI input devices present in the system. The device ID specified by wDeviceID varies from zero to one less than the number of devices present.
If a window is chosen to receive callback information, the following messages are sent to the window procedure function to indicate the progress of MIDI input:
MM_MIM_OPEN
MM_MIM_CLOSE
MM_MIM_DATA
MM_MIM_LONGDATA
MM_MIM_ERROR
MM_MIM_LONGERROR
If a function is chosen to receive callback information, the following messages are sent to the function to indicate the progress of MIDI input:
MIM_OPEN, MIM_CLOSE
MIM_DATA
MIM_LONGDATA
MIM_ERROR
MIM_LONGERROR
The callback function must reside in a DLL. You do not have to use MakeProcInstance to get a procedure-instance address for the callback function.
void FAR PASCAL MidiInFunc(hMidiIn, wMsg, dwInstance, dwParam1, dwParam2)
MidiInFunc is a placeholder for the application-supplied function name. The actual name must be exported by including it in an EXPORTS statement in the DLL's module definition file.
Parameters
HMIDIIN hMidiIn
Specifies a handle to the MIDI input device.
WORD wMsg
Specifies a MIDI input message.
DWORD dwInstance
Specifies the instance data supplied with midiInOpen.
DWORD dwParam1
Specifies a parameter for the message.
DWORD dwParam2
Specifies a parameter for the message.
Comments
Because the callback is accessed at interrupt time, it must reside in a DLL, and its code segment must be specified as FIXED in the module-definition file for the DLL. Any data that the callback accesses must be in a FIXED data segment as well. The callback may not make any system calls except for PostMessage, timeGetSystemTime, timeGetTime, timeSetEvent, timeKillEvent, midiOutShortMsg, midiOutLongMsg, and OutputDebugStr.
midiInClose