How to use callback in a MFC DLL in .NET program?
Dear all,
This may not be the right place to ask this question but it is MFC related:
I have a DLL developed in VS6 using MFC, one of the function is this:
void API::startScan(void (__stdcall *lpfn)(void *status)) {
....
}
lpfn is a callback function supplied by caller(in this case, a function in
my .NET C++ program), status is a pointer to a complex structure inside the
DLL.
I need to copy the data pointed by status in the callback function.
Now I am developing application in VS2005 using .NET CLR
My question is how to implement the callback function and allocate memory
for the structured data for the DLL?
I have tried:
public delegate void delAPI(void *param);
....
delAPI ^delAPIinst;
if(delAPIinst) {
delAPIinst(&i);
}
delAPIinst = gcnew delAPI(this, &Form1::fromAPI);
obj->startScan(delAPIinst);
but the compiler complains:
error C2664: 'API::startScan' : cannot convert parameter 1 from
'tmydll::delAPI ^' to 'void (__stdcall *)(void *)'
Can anyone help me out?
Thanks and best regards,
Tim