这段代码总是出错
尝试读取或写入受保护的内存。这通常指示其他内存已损坏
困扰两天,没能解决!
int ISampleGrabberCB.BufferCB(double SampleTime, IntPtr pBuffer, int BufferLen)内存
{
try
{
if (!mbGotOne)
{
// The buffer should be long enought
if (BufferLen <= mstride * mvideoHeight)
{
// Copy the frame to the buffer
// m_handle = pBuffer;
CopyMemory(mhandle, pBuffer, mstride * mvideoHeight);
// m_handle = pBuffer;
mbGotOne = true;//这里弹出错误。
// Picture is ready.
mpictureReady.Set();
}
}
else
{
mdropped++;
}
}
catch (System.Exception ex)
{
MessageBox.Show(ex.ToString());
}
return 0;
}
[解决办法]
可能是类型大小的问题吧
[解决办法]
这个代码看不出啥。重要的是参数是不是传对了。