I struggled this for a while, still not able to figured out how to write code in C# side
C++ DLL
typedef void (WINAPI *P_HelloWorld)(void);
typedef struct {
P_HelloWorld pHelloWorld;
}FUNC_PARAM;
void Func4(FUNC_PARAM* pFunc)
{
pFunc.pHelloWorld();
}
C# Side:
public delegate void P_HelloWord();
[StructLayout(LayoutKind.Sequential)]
public struct FUNC_PARAM
{
public P_HelloWord pHelloWorld;
}
[DllImport("EMV_DLL.dll")]
public extern static void Func4(FUNC_PARAM[] pFunc);
void main()
{
FUNC_PARAM g;
g.pHelloWorld = new P_HelloWord(this.myHelloWorld);
Func4(new FUNC_PARAM[] { g });
}
void myHelloWorld()
{
MessageBox.Show("My Hello World");
}
The above C# code doesn't work, when execute Func4 function, it throws out of memory exception.
Anybody could help me?
pFunc
parameter is not an array. – David Heffernan Dec 19 '13 at 21:23