/// <summary>
        /// 断开仪器连接
        /// </summary>
        /// <returns></returns>
        public static bool Disconnect()
        {
            OpusCMD334.CheckOpus checkOpus = new OpusCMD334.CheckOpus();
            if (checkOpus == null)
            {
                ErrorString = "Create 'CheckOpus' Error!";
                return(false);
            }
            //OpusCMD334.CloseOpus closeOpus = new OpusCMD334.CloseOpus();
            //if(!closeOpus.CloseOpus())
            //{
            //    ErrorString = "Close OPUS Failed!";
            //    return false;
            //}
            string opus = "opus.exe";

            if (checkOpus.IsOpusRunning(ref opus))
            {
                OpusCMD334.CloseOpus closeOpus = new OpusCMD334.CloseOpus();
                if (!closeOpus.CloseOpus())
                {
                    ErrorString = closeOpus.ErrorDesc;
                    //return false;
                }
            }

            Process[] processes = Process.GetProcessesByName("OPUS");
            if (processes.Length > 0)   //强制关闭OPUS
            {
                for (int i = 0; i < processes.Length; i++)
                {
                    processes[i].Kill();
                }
            }
            return(true);
        }
        /// <summary>
        /// 连接仪器
        /// </summary>
        /// <returns></returns>
        public static bool Connect()
        {
            if (IpAddress == null)
            {
                return(false);
            }
            OpusCMD334.CheckOpus checkOpus = new OpusCMD334.CheckOpus();
            if (!checkOpus.IsOpusRunning("opus.exe"))
            {
                //Disconnect();
                //找到 OPUS安装路径
                string OpusPath = string.Empty;
                Microsoft.Win32.RegistryKey key = Microsoft.Win32.Registry.LocalMachine.OpenSubKey(@"Software\Classes\opus.文件\protocol\StdFileEditing\server", false);
                if (key != null)//判断键值存在
                {
                    string[] ttp = key.GetValueNames();
                    if (ttp == null || ttp.Count() == 0)
                    {
                        return(false);
                    }
                    OpusPath = key.GetValue(ttp[0]).ToString();
                }
                if (string.IsNullOrEmpty(OpusPath))
                {
                    key = Microsoft.Win32.Registry.ClassesRoot.OpenSubKey(@".0\shell\Open\command", false);
                    if (key != null)
                    {
                        string[] ttp = key.GetValueNames();
                        if (ttp == null || ttp.Count() == 0)
                        {
                            return(false);
                        }
                        OpusPath = key.GetValue(ttp[0]).ToString();
                        int i = OpusPath.IndexOf("opus.exe");
                        if (i == -1)
                        {
                            OpusPath = key.GetValue("").ToString();
                            i        = OpusPath.IndexOf("opus.exe");
                        }
                        OpusPath = OpusPath.Substring(1, i + "opus.exe".Length - 1);
                    }
                }
                // 启动OPUS
                OpusCMD334.StartOpus startOpus = new OpusCMD334.StartOpus();
                if (startOpus == null)
                {
                    ErrorString = "Create 'StartOpus' Error!";
                    return(false);
                }
                //"full_access.ows"
                startOpus.StartOpus(OpusPath, "OPUS", null, null, "CHINESE", false);
                System.Diagnostics.Process[] tp = System.Diagnostics.Process.GetProcessesByName("opus");

                if (tp.Count() > 0)
                {
                    int ptr = (tp[0].MainWindowHandle).ToInt32();
                    ShowWindow(ptr, SW_HIDE);
                }
            }
            return(true);
        }