L
lanruishan
Unregistered / Unconfirmed
GUEST, unregistred user!
DLL是别的公司提供的用VC写的视频捕捉开发包<br>其中有一个函数用来启动数据流回调<br>声明原型为:<br>HRESULT DSStream_GetVideoStream(int iCardID, VideoStreamProc proc, LPVOID pParam)<br>其中参数 VideoStreamProc proc是一个回调函数,声明原型<br>extern "c" void proc (const BYTE* pDIBHead, const BYTE* pDIBits, LPVOID pParam)<br><br>我在delphi中调用如下<br>VideoStreamProc = procedure(const pDIBHead: PByte; const pDIBits: PByte; pParam: PVariant);stdcall;<br><br>function DSStream_GetVideoStream(iCardID: integer; proc: VideoStreamProc; pParam: PVariant): HRESULT; cdecl; external dllname;<br><br>我定义了一个回调函数<br>procedure StreamNotify(const pDIBHead: PByte; const pDIBits: PByte; pParam: PVariant);stdcall;<br>var<br> DIBHead: BitmapInfo;<br> hd: Thandle;<br> jpg: TJpegImage;<br> memStream: TStream;<br> Bitmap: TBitmap;<br>begin<br> if (not assigned(pDIBHead)) or (not Assigned(pDIBits)) then<br> exit;<br> DIBHead := PBitmapInfo(pDIBHead)^;<br><br> Bitmap := TBitmap.Create;<br> Bitmap.Width := DIBHead.bmiHeader.biWidth;<br> Bitmap.Height := DIBHead.bmiHeader.biHeight;<br> hd := DrawDibOpen;<br> DrawDibDraw(hd, Bitmap.canvas.handle, 0, 0, DIBHead.BmiHeader.biwidth, DIBHead.bmiheader.biheight,<br> @DIBHead.bmiHeader, pDIBits, 0, 0, DIBHead.bmiHeader.biWidth, DIBHead.bmiHeader.biheight, 0);<br><br> DrawDibClose(hd);<br>//处理数据<br> memStream := TMemoryStream.Create;<br> jpg := TJpegImage.Create;<br> jpg.Assign(Bitmap);<br> //jpg压缩质量<br> jpg.CompressionQuality := 20; //1<br> jpg.JPEGNeeded; //2<br> jpg.Compress; //3<br> jpg.SaveToStream(memStream); //4<br> SendStream(memStream);//这里处理memStream,如:发送到别的客户端<br> jpg.Free;<br> Bitmap.Free;<br> memStream.Free;<br>end;<br><br>这样回调函数调用后,我不在窗体上移动鼠标没有任何错误,但是我一移动鼠标,程序就出错,错误信息为:“企图释放并非呼叫方所拥有的多用户终端运行程序”<br><br>当我把//1 //2 //3 //4处程序注释掉,错误又没有了<br>请各位高手帮我解决这个问题啊,高分求救!