日期:2014-05-18 浏览次数:20977 次
[StructLayout(LayoutKind.Sequential, Pack = 1, CharSet = CharSet.Ansi)] public struct NET_DVR_SHOWSTRINGINFO { //编码端字符叠加配置结构 public ushort dwShowString; public int wStringSize; public ushort wShowStringTopLeftX; public ushort wShowStringTopLeftY; //[MarshalAs(UnmanagedType.LPArray, SizeConst = 44)] //public char[] sString; [MarshalAs(UnmanagedType.ByValTStr, SizeConst = 44)] public string sString; } [StructLayout(LayoutKind.Sequential)] public struct NET_DVR_SHOWSTRING { //叠加字符结构 public int dwSize; public NET_DVR_SHOWSTRINGINFO struStringInfo; } //编码端叠加字符 [DllImport("HCNetSDK.dll")] public static extern bool NET_DVR_SetDVRConfig(int lUserID, int dwCommand, int lChannel, NET_DVR_SHOWSTRING lpInBuffer, int dwInBufferSize); private void button5_Click(object sender, EventArgs e) { NET_DVR_SHOWSTRINGINFO _showstringinfo = new NET_DVR_SHOWSTRINGINFO(); NET_DVR_SHOWSTRING _showstring = new NET_DVR_SHOWSTRING(); string strTT = "我是来测试的!"; _showstring.dwSize = 1; _showstring.struStringInfo = _showstringinfo; _showstring.struStringInfo.dwShowString = 1; _showstring.struStringInfo.sString = strTT; _showstring.struStringInfo.wStringSize = strTT.Length; _showstring.struStringInfo.wShowStringTopLeftX = 100; _showstring.struStringInfo.wShowStringTopLeftY = 100; int iSize= Marshal.SizeOf(_showstring); bool bac = NET_DVR_SetDVRConfig(iLoginRef, 131, 0, _showstring, iSize); if (bac == false) { MessageBox.Show("失败"); } }
/*****************************DS-6001D/F(end)***************************/ //单字符参数(子结构) typedef struct { WORD wShowString; // 预览的图象上是否显示字符,0-不显示,1-显示 区域大小704*576,单个字符的大小为32*32 WORD wStringSize; /* 该行字符的长度,不能大于44个字符 */ WORD wShowStringTopLeftX; /* 字符显示位置的x坐标 */ WORD wShowStringTopLeftY; /* 字符名称显示位置的y坐标 */ char sString[44]; /* 要显示的字符内容 */ }NET_DVR_SHOWSTRINGINFO, *LPNET_DVR_SHOWSTRINGINFO; //叠加字符(9000扩展) typedef struct { DWORD dwSize; NET_DVR_SHOWSTRINGINFO struStringInfo[MAX_STRINGNUM_V30]; /* 要显示的字符内容 */ }NET_DVR_SHOWSTRING_V30, *LPNET_DVR_SHOWSTRING_V30; //叠加字符扩展(8条字符) typedef struct { DWORD dwSize; NET_DVR_SHOWSTRINGINFO struStringInfo[MAX_STRINGNUM_EX]; /* 要显示的字符内容 */ }NET_DVR_SHOWSTRING_EX, *LPNET_DVR_SHOWSTRING_EX; //叠加字符 typedef struct { DWORD dwSize; NET_DVR_SHOWSTRINGINFO struStringInfo[MAX_STRINGNUM]; /* 要显示的字符内容 */ }NET_DVR_SHOWSTRING, *LPNET_DVR_SHOWSTRING; /********************************************************* Function: OnBnClickedBtnStringOk Desc: finish text overlay settings Input: Output: Return: **********************************************************/ void CDlgRemoteShowString::OnBnClickedBtnStringOk() { UpdateData(TRUE); char szLan[128] = {0}; int i = m_comboShowArea.GetCurSel(); m_struShowString.struStringInfo[i].wShowString = (WORD)m_bChkShow; memcpy(m_struShowString.struStringInfo[i].sString, m_csString, 44); m_struShowString.struStringInfo[i].wStringSize = (WORD)strlen(m_csString); m_struShowString.struStringInfo[i].wShowStringTopLeftX = (WORD)m_iStringX; m_struShowString.struStringInfo[i].wShowStringTopLeftY = (WORD)m_iStringY; if (!NET_DVR_SetDVRConfig(m_lLoginID, NET_DVR_SET_SHOWSTRING_V30, m_iChanShowNum, &m_struShowString, sizeof