c#简单金三立视频服务器的调用

1:引用金三立视频服务器提供的二次开发的DLL


2:申明

 [DllImport("videoDll.dll")]
        public static extern bool initNet();
        [DllImport("videoDll.dll")]
        public static extern long
        Dll_setInitServerInfo(string ip, int port, string userName, string passWord, ref ulong m_hUserID);


        [DllImport("videoDll.dll")]
        public static extern ulong
        Dll_PlayVideo(int channelID, int channel_Type, int protocol_type, IntPtr hwnd, ulong m_hUserID);
        [DllImport("videoDll.dll")]
        public static extern bool
        Dll_CloseVideo(int channelID, int channel_Type, ulong m_hPlayID);


        [DllImport("videoDll.dll")]
        public static extern void
        Dll_st_net_ptzControl(int channel, int type, int param, ulong user_id);
        [DllImport("videoDll.dll")]
        public static extern int
        Dll_st_net_setSystemTime(int year, int month, int day, int hour, int minute, int second, ulong user_id);
        [DllImport("videoDll.dll")]
        public static extern bool
        Dll_FreeServerInfo(ulong m_hUserID);

        [DllImport("kernel32")]
        private static extern bool WritePrivateProfileString(string section, string key, string val, string filePath);

        [DllImport("kernel32")]
        private static extern int GetPrivateProfileString(string section, string key, string def, byte[] retVal, int size, string filePath);
        [DllImport("kernel32.dll")]
        public static extern bool Beep(int frequency, int duration);


3:ip与端口,密码,与其他申明

扫描二维码关注公众号,回复: 3844389 查看本文章

   public const int WM_VIDEO = 0x500;
        int currentId = 0;
        private ulong m_hUserID = 0;
        private ulong m_hUserID1 = 0;

        private ulong m_hPlayID1 = 0;
        private ulong m_hPlayID2 = 0;

 string ipAdress = "192.168.1.100";
        const int port = 9660;
        string user = "Admin";
        string password = "123456";

(这种为最简单写死的模式,如果你在实际的开上不能这样干)

4:调用

1:连接

ipAdress = treeView1.SelectedNode.Nodes[1].Text;
                        user = treeView1.SelectedNode.Nodes[2].Text;
                        password = treeView1.SelectedNode.Nodes[3].Text;
                        ipAdress = ipAdress.Substring(5);
                        user = user.Substring(5);
                        password = password.Substring(3);

                        //连接金三立视频服务器
                        Dll_setInitServerInfo(ipAdress, port, user, password, ref m_hUserID);

2:设置时间

if (m_hUserID == 0)
                        {
 
                            currentPositon = "无";
                            return;
                        }
                        Dll_st_net_setSystemTime(DateTime.Now.Year, DateTime.Now.Month, DateTime.Now.Day, DateTime.Now.Hour, DateTime.Now.Minute, DateTime.Now.Second, m_hUserID);

3:打开图像

//通道1

this.m_hPlayID1 = Dll_PlayVideo(0, 0, 1, panel_left.Handle, m_hUserID);
  //通道2

 this.m_hPlayID2 = Dll_PlayVideo(1, 0, 1, panel2.Handle, m_hUserID);


4:设置

 this.m_hPlayID1 = Dll_PlayVideo(1, 0, 1, panel_left.Handle, m_hUserID);

5:调试

Dll_st_net_ptzControl(channel, 0x12, iDefaultPos, userId);

6:上,下,左,右

        private void ControlVideo(int type)
        {
            int channel = comboBox2.SelectedIndex;
            ulong userId = 0;
            if (this.formNum == 0)
            {

                userId = this.m_hUserID;

            }
            else
            {

                userId = this.m_hUserID1;

            }
            Dll_st_net_ptzControl(channel, type, speed, userId);
        }

上面就是是简单的用金三立服务器提供的DLL进行了简单的二次开发。





猜你喜欢

转载自blog.csdn.net/cuiweibin5/article/details/19613551