public class SendImage
{
public delegate int DWatch(int bytesLeftToSend, IntPtr Response);
ret=0xffff;
public void ReadImageFile()
{
int len = 1495;
DWatch pfWatch = DResponse;
IntPtr pfMethod = Marshal.GetFunctionPointerForDelegate(pfWatch);
ret=Send(len, pfMethod);
}
public int DResponse(int bytesLeftToSend, IntPtr Response)
{
//something;
return 0;
}
}
上面的代码显示了如何将代理编组为函数指针。从这我能够回调。但后来我收到内存损坏的错误。请帮忙。谢谢元帅代表函数指针:内存损坏
//unmanaged call in code
int Send(int length, int(*pfMethod)(int bytesLeftToSend, void * Response))
{
int Remaining = 50;
pfMethod(50);
}
你为什么标签这个问题''C'视觉C++'和'C#-4.0' – Eregrith 2012-03-30 12:46:09