Hello @Keitel ,
I have also found that the “rv” variable for midiInStop(hMidiDevice) and midiInClose(hMidiDevice) gives the value 5, which means MMSYSERR_INVALHANDLE, and I don't understand why.
A handle is simply a number that Windows uses for internal reference to an object. In general, a handle becomes invalid after it has been closed.
For suggestions to troubleshoot error "handle is invalid":
- Store the handle value when you get it at the first time. Compare it with the one causes this error. In this question,
hMidiDevice
is released because out of scope. It is never the initial one you got it. - When you found the handle value is incorrect, check if there is any other place close the handle, or it has been changed unexpectedly.
The main problem is however the freezing of the graphic controls.
At first, you can narrow down this issue by excluding unrelated part, this often helps.
Thank you!
If the answer is helpful, please click "Accept Answer" and upvote it.
Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.