static extern int StartVideoPreview(int hChannelHandle,int WndHandle, ref RECT rect,  bool bOverlay, int VideoFormat, int FrameRate);>>>
static extern int StartVideoPreview(IntPtr hChannelHandle,IntPtr WndHandle, ref RECT rect,bool bOverlay, int VideoFormat, int FrameRate);估计是类型不匹配

解决方案 »

  1.   

    关注,有解决办法了请告诉我。谢谢!
    [email protected]
      

  2.   

    函数返回值是对的  是0 符合 它的说明
    下面是我实际调用的代码 
    int xx=hkVideo.startVideoPreview( y,this.Handle.ToInt32() ,ref z,false, HkVideo.vdfRGB16 , 25 );
      

  3.   

    static extern int StartVideoPreview(int hChannelHandle,int WndHandle, ref RECT rect,  bool bOverlay, int VideoFormat, int FrameRate);<<<<<<<<<<<<<<<<<<<
    这里申明错误。WIN32 API中的HANDLE类型和HWND类型是和C#中的IntPtr类型对应的,不是int。另外API中的指针在C#(unsafe)中是和IntPtr.ToPointer();对应的。
    Hope it would help you !
      

  4.   

    谢谢 楼上的 兄弟 
    在问句  你说指针不是用ref 那用什么 呢?
      

  5.   

    能不能给出函数的定义给我看看  要在unsafe里吗  怎么用 能详细点吗
      

  6.   

    From MSDN:-------------
    Provides a wrapper class for pointers.For a list of all members of this type, see Pointer Members.System.Object
       System.Reflection.Pointer
    [CLSCompliant(false)]
    public sealed class Pointer : ISerializable--------------
    And for more detail ,you can refer to MSDN about Pointer.Box(..) and Pointer.UnBox(...)
      

  7.   

    Box 把非托管类型的指针转换为托管类型的对象(Pointer)
    UnBox 与Box相反
      

  8.   

    是不是这样写 
    using  System.Reflection;
    [DllImport("tmSDK.dll")]
    static extern int StartVideoPreview( IntPtr hChannelHandle,IntPtr WndHandle, Pointer  rect, 
    bool bOverlay, int VideoFormat, int FrameRate);
      

  9.   

    怎么样使用阿
    怎样定义一个指向RECT的Pointer啊  
      

  10.   

    http://www.codeproject.com/cs/media/directxcapture.asp
      

  11.   

    是不是这样写 
    using  System.Reflection;
    [DllImport("tmSDK.dll")]
    static extern int StartVideoPreview( IntPtr hChannelHandle,IntPtr WndHandle, Pointer  rect, 
    bool bOverlay, int VideoFormat, int FrameRate);怎么样使用阿
    怎样定义一个指向RECT的Pointer啊  
      

  12.   

    struct is a valuetype,declare the parameters [in] or [out] can help you when you work with WIN32 API.using  System.Reflection;
    [DllImport("tmSDK.dll")]
    static extern int StartVideoPreview( IntPtr hChannelHandle,IntPtr WndHandle, [out,in] RECT rect,bool bOverlay, int VideoFormat, int FrameRate);<---------OR--------->using  System.Reflection;
    [DllImport("tmSDK.dll")]
    static extern int StartVideoPreview( IntPtr hChannelHandle,IntPtr WndHandle, [out] RECT rect,bool bOverlay, int VideoFormat, int FrameRate);
      

  13.   

    A sample From dy630(半导体) 
    >>>>>>
    int GetVideoPosition(
    [Out, MarshalAs(UnmanagedType.LPStruct)] out RECT lpSRCRect,
    [Out, MarshalAs(UnmanagedType.LPStruct)] out RECT lpDSTRect
    );
    >>>>>>API Definetion>>>>>
    HRESULT GetVideoPosition(
      RECT *pSourceRect,
      RECT *pDestinationRect
    );
      

  14.   

    好象还是不行哦
    我把这个dll接口及其说明抄给大家看看int StartVideoPreview(HANDLE hChannelHandle,HWND WndHandle, RECT *rect, BOOLEAN bOverlay, int VideoFormat, int FrameRate); 
    参数: HANDLE hChannelHandle 通道句柄 HWND WndHandle, 窗口句柄 RECT *rect, 窗口内的矩型区域 BOOLEAN bOverlay, 打开或关闭Overlay模式预览 int VideoFormat, 视频格式(见2.1节) int FrameRate 视频帧率 说明: 启动视频预览, 如果在VideoFormat 中设置为YUV类型,则系统中的显示卡必须支持硬件Overlay功能,显示卡的颜色必须为16位色或32位色;如果VideoFormat设置为RGB类型,则采用DDRAW模式显示,即视频窗口会覆盖所有位于窗口范围内的图像; 返回: 正确为0, 其他为第1节定义的错误号;