[RESOLVED] Callback from C++ DLL using fixed length array
I have an C++ DLL into which I need to register a Callback.
My problem is that the C++ DLL expects fixed length arrays. How do I need to delcare the arrays in the CallBack and the Function.
The C++ Type is delcalred as
Code:
typedef void (*Full_Callback) (int Site, bool Change(8));
Re: Callback from C++ DLL using fixed length array
found the "solution" by myself.
Instead of the expected fixed array, I delcare a matching Structure that holds all variables.
for the above Callback in the DLL I use:
Code:
Public Structure strucChange
Public Bool0 As Boolean
Public Bool1 As Boolean
Public Bool2 As Boolean
Public Bool3 As Boolean
Public Bool4 As Boolean
Public Bool5 As Boolean
Public Bool6 As Boolean
Public Bool7 As Boolean
End Structure
<UnmanagedfunctionPointer(CallingConvention.Cdecl)> Public Delegate Sub DelCallback(ByVal Site as Integer, ByRef Change As strucChange)
<DllImport("MyLib.dll", Entrypoint:="Full_Callback", setlasterror:=True, CharSet:= CharSet.Ansi, exactspelling:=True; CallingConvention:=CallingConvention.Cdecl)>_
Public Shared Sub FullCallback( ByVal Active As Boolean, ByVal CallbackAddr As DelCallback)
End Sub
of course there is also a Sub with the same parameters as in the DelCallback definition.