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);估计是类型不匹配
static extern int StartVideoPreview(IntPtr hChannelHandle,IntPtr WndHandle, ref RECT rect,bool bOverlay, int VideoFormat, int FrameRate);估计是类型不匹配
[email protected]
下面是我实际调用的代码
int xx=hkVideo.startVideoPreview( y,this.Handle.ToInt32() ,ref z,false, HkVideo.vdfRGB16 , 25 );
这里申明错误。WIN32 API中的HANDLE类型和HWND类型是和C#中的IntPtr类型对应的,不是int。另外API中的指针在C#(unsafe)中是和IntPtr.ToPointer();对应的。
Hope it would help you !
在问句 你说指针不是用ref 那用什么 呢?
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(...)
UnBox 与Box相反
using System.Reflection;
[DllImport("tmSDK.dll")]
static extern int StartVideoPreview( IntPtr hChannelHandle,IntPtr WndHandle, Pointer rect,
bool bOverlay, int VideoFormat, int FrameRate);
怎样定义一个指向RECT的Pointer啊
using System.Reflection;
[DllImport("tmSDK.dll")]
static extern int StartVideoPreview( IntPtr hChannelHandle,IntPtr WndHandle, Pointer rect,
bool bOverlay, int VideoFormat, int FrameRate);怎么样使用阿
怎样定义一个指向RECT的Pointer啊
[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);
>>>>>>
int GetVideoPosition(
[Out, MarshalAs(UnmanagedType.LPStruct)] out RECT lpSRCRect,
[Out, MarshalAs(UnmanagedType.LPStruct)] out RECT lpDSTRect
);
>>>>>>API Definetion>>>>>
HRESULT GetVideoPosition(
RECT *pSourceRect,
RECT *pDestinationRect
);
我把这个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节定义的错误号;