private FormRecord[] recordFrm = new FormRecord[9];  //9 个录像界面
        // 录像点击时 开始录像
        private void cmsLX_Click(object sender, EventArgs e)
        {
            PictureBox pic   = (PictureBox)(cms.SourceControl);
            int        index = int.Parse(pic.Name);

            if (index == 0)
            {
                threadRunning = false;      // 线程空运行  只对第一个通道做处理
            }
            if (m_lRealHandle[index] >= 0)  // 如果在预览
            {
                string path = ClassXml.getSetXml("record");
                if (!Directory.Exists(path))
                {
                    Directory.CreateDirectory(path);
                }
                //图片名称 年月日 时分秒
                string FileName = System.DateTime.Now.ToString("yyMMddhhmmss");
                FileName = path + "\\" + FileName + ".mp4";

                //mp4录像
                if (m_bRecord[index] == false)    //开始录像
                {
                    //强制I帧 Make one key frame
                    int lChannel = iChannelNum[index]; //通道号 Channel number
                    CHCNetSDK.NET_DVR_MakeKeyFrame(m_lUserID, lChannel);

                    //开始录像 Start recording
                    if (!CHCNetSDK.NET_DVR_SaveRealData(m_lRealHandle[index], FileName))
                    {
                        iLastErr = CHCNetSDK.NET_DVR_GetLastError();
                        toolStripStatusLabel6.Text = "录像失败,错误代码" + iLastErr.ToString();
                        return;
                    }
                    else
                    {
                        toolStripStatusLabel6.Text = "开始录像,保存文件名为" + FileName;
                        m_bRecord[index]           = true;
                        recordFrm[index]           = new FormRecord();
                        recordFrm[index].index     = index;
                        recordFrm[index].Owner     = this;
                        recordFrm[index].path      = FileName;
                        recordFrm[index].Show();  // 显示录像界面
                    }
                }
                else  //打开录像界面
                {
                    if (recordFrm[index] != null)
                    {
                        recordFrm[index].WindowState = FormWindowState.Normal;
                    }
                    //停止录像 Stop recording

                    /*CHCNetSDK.NET_DVR_StopSaveRealData(m_lRealHandle[index]);
                     * m_bRecord[index] = false;   */
                }
            }
        }
        // 开始录像
        private void startRecord()
        {
            threadRunning = false; // 线程空运行
            if (soundonoff)        // 如果发出警报
            {
                Beep(600, 1000);   // 发出警告声音
            }
            // 开始录像
            if (m_lRealHandle[0] >= 0)  // 如果在预览
            {
                string path = ClassXml.getSetXml("record");
                if (!Directory.Exists(path))
                {
                    Directory.CreateDirectory(path);
                }
                //图片名称 年月日 时分秒
                string FileName = System.DateTime.Now.ToString("yyMMddhhmmss");
                FileName = path + "\\" + FileName + ".mp4";

                //mp4录像
                if (m_bRecord[0] == false)    //开始录像
                {
                    //强制I帧 Make one key frame
                    int lChannel = iChannelNum[0]; //通道号 Channel number
                    CHCNetSDK.NET_DVR_MakeKeyFrame(m_lUserID, lChannel);

                    //开始录像 Start recording
                    if (!CHCNetSDK.NET_DVR_SaveRealData(m_lRealHandle[0], FileName))
                    {
                        iLastErr = CHCNetSDK.NET_DVR_GetLastError();
                        toolStripStatusLabel6.Text = "录像失败,错误代码" + iLastErr.ToString();
                        return;
                    }
                    else
                    {
                        toolStripStatusLabel6.Text = "开始录像,保存文件名为" + FileName;
                        m_bRecord[0]       = true;
                        recordFrm[0]       = new FormRecord();
                        recordFrm[0].index = 0;
                        recordFrm[0].Owner = this;
                        recordFrm[0].path  = FileName;
                        recordFrm[0].Show();  // 显示录像界面
                    }
                }
                else  //打开录像界面
                {
                    if (recordFrm[0] != null)
                    {
                        recordFrm[0].WindowState = FormWindowState.Normal;
                    }
                }
            }
        }