R
R. van der Welle
Hi All,
I am upgrading my app (working well with VB6) to VB.NET. It sends MIDI
messages using the API multimedia winmm.dll .
These functions are declared:
Public Declare Function timeSetEvent Lib "winmm.dll" (ByVal uDelay As
Integer, _
ByVal uResolution As Integer, ByVal lpFunction As MidiPlayDelegate, _
ByVal dwUser As Integer, ByVal uFlags As Integer) As Integer
Delegate Function MidiPlayDelegate(ByVal lTimerID As Integer, ByVal dwMsg As
Integer, _
ByVal dwUser As Integer, ByVal lParam1 As Integer, ByVal lParam2 As
Integer) As Integer
and a function MidiPlay is available:
Public Function MidiPlay(ByVal lTimerID As Integer, ByVal dwMsg As Integer,
_
ByVal dwUser As Integer, ByVal lParam1 As Integer, ByVal lParam2 As
Integer) As Integer
...
lRet = midiOutShortMsg(hMidiOut, mididata)
...
End Function
----------------------------------------------------------------------------
-----
A MIDI port is opened by a call to midiOutOpen, then a timer is started by
the statement
lTimerID = timeSetEvent(1, 1, AddressOf MidiPlay, 0, 1)
which runs in its own thread.
On each time event the call back function MidiPlay is called, which in turn
sends the MIDI data through
lRet = midiOutShortMsg(hMidiOut, mididata)
When the program is run a System.NullReferenceException occurs in an Unknown
Module (the
MidiPlayDelegate, I guess), because
"Object reference not set to an instance of an object"
Which object reference should be set?
Thank you for your help,
ReinierVDW
I am upgrading my app (working well with VB6) to VB.NET. It sends MIDI
messages using the API multimedia winmm.dll .
These functions are declared:
Public Declare Function timeSetEvent Lib "winmm.dll" (ByVal uDelay As
Integer, _
ByVal uResolution As Integer, ByVal lpFunction As MidiPlayDelegate, _
ByVal dwUser As Integer, ByVal uFlags As Integer) As Integer
Delegate Function MidiPlayDelegate(ByVal lTimerID As Integer, ByVal dwMsg As
Integer, _
ByVal dwUser As Integer, ByVal lParam1 As Integer, ByVal lParam2 As
Integer) As Integer
and a function MidiPlay is available:
Public Function MidiPlay(ByVal lTimerID As Integer, ByVal dwMsg As Integer,
_
ByVal dwUser As Integer, ByVal lParam1 As Integer, ByVal lParam2 As
Integer) As Integer
...
lRet = midiOutShortMsg(hMidiOut, mididata)
...
End Function
----------------------------------------------------------------------------
-----
A MIDI port is opened by a call to midiOutOpen, then a timer is started by
the statement
lTimerID = timeSetEvent(1, 1, AddressOf MidiPlay, 0, 1)
which runs in its own thread.
On each time event the call back function MidiPlay is called, which in turn
sends the MIDI data through
lRet = midiOutShortMsg(hMidiOut, mididata)
When the program is run a System.NullReferenceException occurs in an Unknown
Module (the
MidiPlayDelegate, I guess), because
"Object reference not set to an instance of an object"
Which object reference should be set?
Thank you for your help,
ReinierVDW