B
BoloBaby
OK, here's the problem...
I have a digital input/output card that exposes IRQs (digital input
change-of-state) through a DLL function.
In VB6.0, I can use this ability through code that looks like this:
[Class1]
Public sub test()
DIO_INT1_EventMessage 0, 0, 0, 0, AddressOf BE_ReadPort
end sub
[standard module]
Declare Function DIO_INT1_EventMessage Lib "Pci-Dask.dll" (ByVal CardNumber
As Integer, ByVal Int1Mode As Integer, ByVal windowHandle As Long, ByVal
message As Long, ByVal callbackAddr As Long) As Integer
Public sub BE_ReadPort()
'do some stuff
end sub
Take note that the sub that handles the event HAS to be in the standard
module and NOT in a class module. This is just a limitation of VB6.0. This
means that I can't raise any events in that sub... which is what I *really*
need to do.
Anyway, the inability to raise events led me to try and set up a PInvoke
wrapper in .NET. The problem is, the VB6.0 DLL for the digital I/O card
accepts only "ByVal callbackAddr As Long" as the address for the callback
function. In .NET, the AddressOf operator returns a System.Delegate type.
How can I make this code point to my delegate function in .NET? Or,
alternatively, how can I use VB6.0 to raise the event? I already tried
using a global object to raise the events. Doesn't seem to work...
Thanks.
I have a digital input/output card that exposes IRQs (digital input
change-of-state) through a DLL function.
In VB6.0, I can use this ability through code that looks like this:
[Class1]
Public sub test()
DIO_INT1_EventMessage 0, 0, 0, 0, AddressOf BE_ReadPort
end sub
[standard module]
Declare Function DIO_INT1_EventMessage Lib "Pci-Dask.dll" (ByVal CardNumber
As Integer, ByVal Int1Mode As Integer, ByVal windowHandle As Long, ByVal
message As Long, ByVal callbackAddr As Long) As Integer
Public sub BE_ReadPort()
'do some stuff
end sub
Take note that the sub that handles the event HAS to be in the standard
module and NOT in a class module. This is just a limitation of VB6.0. This
means that I can't raise any events in that sub... which is what I *really*
need to do.
Anyway, the inability to raise events led me to try and set up a PInvoke
wrapper in .NET. The problem is, the VB6.0 DLL for the digital I/O card
accepts only "ByVal callbackAddr As Long" as the address for the callback
function. In .NET, the AddressOf operator returns a System.Delegate type.
How can I make this code point to my delegate function in .NET? Or,
alternatively, how can I use VB6.0 to raise the event? I already tried
using a global object to raise the events. Doesn't seem to work...
Thanks.