How to pass a function pointer to a DLL ?

BlitzMax Forums/BlitzMax Programming/How to pass a function pointer to a DLL ?

semar(Posted 2005) [#1]
Hi all,
In the winmm.dll there is this function:
Function MidiInOpen(lphMidiIn:Byte Ptr, uDeviceID:Byte Ptr, dwCallback:Byte Ptr, dwInstance:Byte Ptr, dwFlags:Int)

Which I declare with an Extern...End Extern from within BMAX.

So, for the parameter dwCallback I have to pass a function pointer.

The question: how can I pass a BMAX function pointer to that DLL function ?

A working example would be really appreciated.

Regards,
Sergio.


Perturbatio(Posted 2005) [#2]
Not a working example with winmm but it shows that conversion between a function pointer and a byte ptr is easy enough to do.

Local fpointer:Byte Ptr

fpointer = test

Local p() = fpointer
p()

End

Function test()
Print "test"
End Function