日期:2014-05-17  浏览次数:20733 次

这段代码总是出错
尝试读取或写入受保护的内存。这通常指示其他内存已损坏
困扰两天,没能解决!
        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());
           &n