调用第三方动态库,对方提供的函数
int __stdcall StartVideoPreview(HANDLE hChannelHandle,HWND WndHandle, RECT *rect,BOOLEAN bOverlay, int VideoFormat, int FrameRate) 
HANDLE hChannelHandle;通道句柄 
HWND WndHandle;显示窗口句柄 
RECT *rect;显示窗口内的矩形区域 
BOOLEAN bOverlay;是否启用 Overlay预览模式* 
int VideoFormat;视频预览格式(目前无效) 
int FrameRate;视频预览帧率(PAL:1-25,NTSC:1-30) 我用C#是这么写的
SysJianKong.CSRect rc = new SysJianKong.CSRect();
rc.left = 0;
rc.top = 5;
rc.right = this.panel1.Size.Width;
rc.bottom = this.panel1.Size.Height;
IntPtr intptr = SysJianKong.ChannelOpen(4)
SysJianKong.StartVideoPreview(intptr, this.panel1.Handle, rc, false, 0,25);
//class SysJianKong 中定义
[DllImport("DS40xxSDK.dll", EntryPoint = "StartVideoPreview")]
public static extern int StartVideoPreview(IntPtr hChannelHandle, IntPtr WndHandle, CSRect rect, bool bOverlay, int VideoFormat, int FrameRate);        public struct CSRect
        {
            public int bottom;
            public int left;
            public int right;
            public int top;
        }
可是总是报一个错误 “尝试读取或写入受保护的内存。这通常指示其他内存已损坏”
高手帮忙 急!!!

解决方案 »

  1.   

    [DllImport("DS40xxSDK.dll", EntryPoint = "StartVideoPreview")]
    public static extern int StartVideoPreview(IntPtr hChannelHandle, IntPtr WndHandle, IntPtr rect, bool bOverlay, int VideoFormat, int FrameRate);
      

  2.   

    public struct CSRectSharp
    {
       public int bottom;
       public int left;
       public int right;
       public int top;
    } StartVideoPreview(hChannelHandle, WndHandle, rect, bOverlay, VideoFormat, FrameRate);
    CSRectSharp csr = (CSRectSharp)Marshal.PtrToStructure(rect , typeof(CSRectSharp));
      

  3.   

    推荐一篇文章给你看:http://www.cnblogs.com/yiki/archive/2008/10/29/1321848.html
    自己对照下,就差不多了