I have found many examples that I thought may help but I cannot get my head around callback functions from the c++ DLL.
I have the following code
global.cs
In my own code I have tried a few things but basically want the following functionalityCode:[DllImport("my.dll")] unsafe public static extern UInt16 RegisterDetectCallback(void* detectCallbackFunction);
program.cs
I have tried a few things without success, can anybody point me in the right direction please? i know the above is incorrect as the DLL requires a pointer and i'm trying to pass a function, but hopefully the intention is clear.Code:public void DetectCallback() { // some functionality... } private void button1_Click(object sender, EventArgs e) { //various code... UInt16 result = DLLFunctions.RegisterDetectCallback(DetectCallback()); }
Also is it possible to do this without unsafe code? without changing the c++, or is this a requirement when passing functions as parameters in this way?
Thanks
Matt




Reply With Quote