/// <summary> /// 开窗设置 /// </summary> /// <param name="info">窗口操作信息</param> /// <returns>TRUE:成功 FALSE:失败</returns> public static bool WallSetWinCfg(WinCtrlInfo info) { NET_DVR_VIDEOWALLWINDOWPOSITION m_struWinCfg = new NET_DVR_VIDEOWALLWINDOWPOSITION(); uint m_dwWallNo = info.WallNo; uint m_dwRes = 0; uint m_dwWinNo = info.WinNo; //窗口号(组合):1字节电视墙号+1字节保留+2字节窗口号 uint dwWinNum = ((m_dwWallNo & 0xff) << 24) + ((m_dwRes & 0xff) << 16) + (m_dwWinNo & 0xff); /////////////////////////////////////////////////////////////////////////////// //输入参数 NET_DVR_IN_PARAM struInputParam = new NET_DVR_IN_PARAM(); IntPtr lpBuf = Marshal.AllocHGlobal(4); Marshal.StructureToPtr(dwWinNum, lpBuf, false); struInputParam.struCondBuf.pBuf = lpBuf; //输入参数缓冲区,开窗的电视墙号,窗口号由设备自动分配 struInputParam.struCondBuf.nLen = 4; //窗口参数,包括使能、位置坐标等 m_struWinCfg.dwSize = (uint)Marshal.SizeOf(m_struWinCfg); m_struWinCfg.byEnable = info.IsEnable; m_struWinCfg.struRect.dwXCoordinate = ushort.Parse((info.IndexX * winBaseX).ToString()); m_struWinCfg.struRect.dwYCoordinate = ushort.Parse((info.IndexY * winBaseY).ToString()); m_struWinCfg.struRect.dwWidth = winBaseX; m_struWinCfg.struRect.dwHeight = winBaseY; Int32 nSize = Marshal.SizeOf(m_struWinCfg); IntPtr lpInBuf = Marshal.AllocHGlobal(nSize); Marshal.StructureToPtr(m_struWinCfg, lpInBuf, false); struInputParam.struInParamBuf.pBuf = lpInBuf; //输入参数缓冲区,开窗的窗口参数 struInputParam.struInParamBuf.nLen = (uint)nSize; struInputParam.dwRecvTimeOut = 0; //数据接收超时时间,0表示接口默认超时 ///////////////////////////////////////////////////////////////////////////// //输出参数 NET_DVR_OUT_PARAM struOutParam = new NET_DVR_OUT_PARAM(); //输出参数缓冲区,dwCount个窗口号(组合),dwCount为0 IntPtr lpOutBuf = Marshal.AllocHGlobal(4); Marshal.StructureToPtr(dwWinNum, lpOutBuf, false); struOutParam.struOutBuf.pBuf = lpOutBuf; struOutParam.struOutBuf.nLen = 4; //状态参数 UInt32 dwStatusList = 0; IntPtr lpStatusList = Marshal.AllocHGlobal(4); Marshal.StructureToPtr(dwStatusList, lpStatusList, false); bool b = NET_DVR_SetDeviceConfigEx(info.UserId, NET_DVR_SET_VIDEOWALLWINDOWPOSITION, 1, ref struInputParam, ref struOutParam); if (!b) { iLastErr = NET_DVR_GetLastError(); strErr = "NET_DVR_SET_VIDEOWALLWINDOWPOSITION failed, error code= " + iLastErr; //设置窗口参数失败,输出错误号 Failed to set the window parameters of device and output the error code } Marshal.FreeHGlobal(lpBuf); Marshal.FreeHGlobal(lpInBuf); Marshal.FreeHGlobal(lpOutBuf); Marshal.FreeHGlobal(lpStatusList); return(b); }
public static extern bool NET_DVR_SetDeviceConfigEx(Int32 lUserID, uint dwCommand, uint dwCount, ref NET_DVR_IN_PARAM lpInParam, ref NET_DVR_OUT_PARAM lpOutParam);