Ejemplo n.º 1
0
        private void ToolStripMenuItemSaveAs_Click(object sender, EventArgs e)
        {
            HaspFeature feature = HaspFeature.Default;

            Hasp       hasp   = new Hasp(feature);
            HaspStatus status = hasp.Login(_vendorCode);

            var haspStatus = getHaspStatusMessage(status);

            if (haspStatus != "OK")
            {
                var res = MessageBox.Show(
                    "HASP HL key has been removed. If you need to save the file, click Cancel and save it",
                    "Error",
                    MessageBoxButtons.OKCancel,
                    MessageBoxIcon.Error
                    );

                if (res == DialogResult.OK)
                {
                    Close();
                }
            }
            SaveFile();
        }
        /// <summary>
        /// constructor
        /// </summary>
        public HaspDongle(int inProductcode, ushort inClientcode)
        {
            mProductcode  = inProductcode;//1001;// 1050;
            mCRCTable     = new uint[256];
            mKey          = 0;
            mClient       = inClientcode;
            mLicenseCount = 0;

            options = FeatureOptions.NotRemote;
            feature = HaspFeature.ProgNumDefault;
            feature.SetOptions(options, FeatureOptions.Default);

            hasp = new Hasp(feature);

            mLicenses = new List <License>();

            // first get the right key!
            using (hasp)
            {
                mKey = GetKey();
                if (mKey != 0 && hasp != null)
                {
                    GetGeneralInfo();
                    if (mLicenseCount > 0)
                    {
                        GetLicenses();
                    }
                }
            }
        }
Ejemplo n.º 3
0
        public string loginstate(string slCode)
        {
            HaspFeature feature = HaspFeature.Default;

            Hasp       hasp   = new Hasp(feature);
            HaspStatus status = hasp.Login(safeNetEntity.vendorCode, safeNetEntity.loginScope.Replace("{slcode}", slCode));

            return(status.ToString());
        }
Ejemplo n.º 4
0
        private void FormMain_FormClosing(object sender, FormClosingEventArgs e)
        {
            HaspFeature feature = HaspFeature.Default;

            Hasp       hasp   = new Hasp(feature);
            HaspStatus status = hasp.Logout();

            getHaspStatusMessage(status);
        }
Ejemplo n.º 5
0
        /// <summary>
        /// 返回ID
        /// </summary>
        /// <param name="tz">厂商</param>
        /// <param name="id">ID</param>
        /// <param name="er">错误代码</param>
        /// <returns></returns>
        public HaspStatus time(int tz, out string id, out string er)
        {
            id = string.Empty;

            er = string.Empty;

            try
            {
                string DateTime = string.Empty;
                scope = defaultScope;

                HaspFeature feature = HaspFeature.FromFeature(tz);

                hasp = new Hasp(feature);

                HaspStatus status = hasp.Login(strVendorCode, scope);

                if (status != HaspStatus.StatusOk)
                {
                    er = status.ToString();
                    return(status);
                }
                er = Convert.ToString(status);
                string xlmFile = "<haspformat root=" + "\"" + "hasp_info" + "\"" + ">" +
                                 "<hasp>" +
                                 "<attribute name=" + "\"" + "id" + "\"" + "/>" +
                                 "<feature>" +
                                 "<element name=" + "\"" + "license" + "\"" + "/>" +
                                 "</feature>" +
                                 "</hasp>" +
                                 "</haspformat>";

                string info = string.Empty;

                string Time2 = hasp.GetSessionInfo(xlmFile, ref info).ToString();

                string[] sArray = info.Split(new char[2] {
                    '"', '"'
                });

                if (sArray.Length > 6)
                {
                    id = sArray[5];
                }

                //释放内存
                status = hasp.Logout();

                return(status);
            }
            catch (Exception ex)
            {
                er = ex.ToString();
                return(HaspStatus.SystemError);
            }
        }
Ejemplo n.º 6
0
        /// <summary>
        ///     Uses pre-defined vendor code for validating whether the HASP software license installed on the server is valid or not
        ///     Returns the detailed hasp pass/fail message only
        /// </summary>
        /// <remarks>
        ///     The HASP dlls (hasp_net_windows.dll, hasp_windows_x64_102489.dll, haspvlib_102489.dll, and hasp_windows_102489.dll)
        ///     must be placed in the windows system directory in order for IIS to access those external dlls
        /// </remarks>
        public static string validateLicenseDetails()
        {
            // Sentinel LDK API
            HaspFeature feature = HaspFeature.FromFeature(1001);  // Using feature 1 defined in EMS-Server; Actual product should be using 1001

            Hasp       hasp   = new Hasp(feature);
            HaspStatus status = hasp.Login(getVendorCode());

            return(status.ToString());
        }
Ejemplo n.º 7
0
        public bool login(string slCode)
        {
            bool        rtn     = false;
            HaspFeature feature = HaspFeature.Default;

            Hasp       hasp   = new Hasp(feature);
            HaspStatus status = hasp.Login(safeNetEntity.vendorCode, safeNetEntity.loginScope.Replace("{slcode}", slCode));

            if (HaspStatus.StatusOk == status)
            {
                rtn = true;
            }
            return(rtn);
        }
Ejemplo n.º 8
0
        public bool logout()
        {
            bool        rtn     = false;
            HaspFeature feature = HaspFeature.Default;

            Hasp       hasp   = new Hasp(feature);
            HaspStatus status = hasp.Logout();

            if (HaspStatus.StatusOk == status)
            {
                rtn = true;
            }
            return(rtn);
        }
Ejemplo n.º 9
0
        /// <summary>
        ///     Uses pre-defined vendor code for validating whether the HASP software license installed on the server is valid or not
        /// </summary>
        /// <remarks>
        ///     The HASP dlls (hasp_net_windows.dll, hasp_windows_x64_102489.dll, haspvlib_102489.dll, and hasp_windows_102489.dll)
        ///     must be placed in the windows system directory in order for IIS to access those external dlls
        /// </remarks>
        public static bool validateLicense()
        {
            // Sentinel LDK API
            HaspFeature feature = HaspFeature.FromFeature(1001);  // Using feature 1 defined in EMS-Server; Actual product should be using 1001

            Hasp       hasp   = new Hasp(feature);
            HaspStatus status = hasp.Login(getVendorCode());

            if (HaspStatus.StatusOk != status)
            {
                return(false);
            }
            else
            {
                return(true);
            }
        }
Ejemplo n.º 10
0
    /// <summary>
    /// Demonstrates how to perform a login using the default
    /// feature and how to perform an automatic logout
    /// using the Hasp's Dispose method.
    /// </summary>
    public void LoginDisposeDemo()
    {
        Verbose("Login/Dispose Demo with Default Feature (HaspFeature.Default)");

        HaspFeature feature = HaspFeature.Default;

        Hasp hasp = new Hasp(feature);

        HaspStatus status = hasp.Login(VendorCode.Code, scope);

        ReportStatus(status);

        Verbose("Disposing object - will perform an automatic logout");
        hasp.Dispose();

        Verbose("");
    }
Ejemplo n.º 11
0
    /// <summary>
    /// Demonstrates how to login using a feature id.
    /// </summary>
    public Hasp LoginDemo(HaspFeature feature)
    {
        //Verbose("Login Demo with Feature: " +
        //        feature.FeatureId.ToString() +
        //        (feature.IsProgNum ? " (Program Number)" : ""));

        // create a key object using a feature
        // and perform a login using the vendor code.
        Hasp hasp = new Hasp(feature);

        HaspStatus status = hasp.Login(VendorCode.Code, scope);

        ReportStatus(status);

        //Verbose("");

        return(hasp.IsLoggedIn() ? hasp : null);
    }
Ejemplo n.º 12
0
    /// <summary>
    /// Demonstrates how to perform a login and an automatic
    /// logout using C#'s scope clause.
    /// </summary>
    public void LoginDefaultAutoDemo()
    {
        Verbose("Login Demo with Default Feature (HaspFeature.Default)");

        HaspFeature feature = HaspFeature.Default;

        // this will perform a logout and object disposal
        // when the using scope is left.
        using (Hasp hasp = new Hasp(feature))
        {
            HaspStatus status = hasp.Login(VendorCode.Code, scope);
            ReportStatus(status);

            Verbose("Object going out of scope - System will call Dispose");
        }

        Verbose("");
    }
Ejemplo n.º 13
0
        private void FormMain_Load(object sender, EventArgs e)
        {
            HaspFeature feature = HaspFeature.Default;

            Hasp       hasp   = new Hasp(feature);
            HaspStatus status = hasp.Login(_vendorCode);

            var haspStatus = getHaspStatusMessage(status);

            if (Properties.Settings.Default.number_of_starts < 5 && haspStatus == "OK")
            {
                Properties.Settings.Default.hasp_plugged_in = true;
            }

            if (haspStatus != "OK" && Properties.Settings.Default.hasp_plugged_in)
            {
                var res = MessageBox.Show(
                    "The key was plugged in once. Plug it in again",
                    "Error",
                    MessageBoxButtons.OK,
                    MessageBoxIcon.Error
                    );

                if (res == DialogResult.OK)
                {
                    Close();
                }
            }

            if (Properties.Settings.Default.number_of_starts >= 5 && haspStatus != "OK")
            {
                var res = MessageBox.Show(
                    haspStatus,
                    "Error",
                    MessageBoxButtons.OK,
                    MessageBoxIcon.Error
                    );

                if (res == DialogResult.OK)
                {
                    Close();
                }
            }
        }
Ejemplo n.º 14
0
    /// <summary>
    /// Demonstrates how to login into a key using the
    /// default feature. The default feature is ALWAYS
    /// available in every key.
    /// </summary>
    public Hasp LoginDefaultDemo()
    {
        Verbose("Login Demo with Default Feature (HaspFeature.Default)");

        HaspFeature feature = HaspFeature.Default;

        Hasp hasp = new Hasp(feature);

        HaspStatus status = hasp.Login(VendorCode.Code, scope);

        ReportStatus(status);
        Verbose("");

        // Please note that there is no need to call
        // a logout function explicitly - although it is
        // recommended. The garbage collector will perform
        // the logout when disposing the object.
        // If you need more control over the logout procedure
        // perform one of the more advanced tasks.
        return(hasp.IsLoggedIn() ? hasp : null);
    }
Ejemplo n.º 15
0
        private void ToolStripMenuItemOpen_Click(object sender, EventArgs e)
        {
            HaspFeature feature = HaspFeature.Default;

            Hasp       hasp   = new Hasp(feature);
            HaspStatus status = hasp.Login(_vendorCode);

            var haspStatus = getHaspStatusMessage(status);

            if (haspStatus != "OK")
            {
                var res = MessageBox.Show(
                    "HASP HL key has been removed. If you need to save the file, click Cancel and save it",
                    "Error",
                    MessageBoxButtons.OKCancel,
                    MessageBoxIcon.Error
                    );

                if (res == DialogResult.OK)
                {
                    Close();
                }
            }

            OpenFileDialog openFileDialog = new OpenFileDialog();

            if (openFileDialog.ShowDialog() == DialogResult.OK)
            {
                _openedFile = openFileDialog.FileName;
                try
                {
                    richTextBoxMain.Text = File.ReadAllText(_openedFile);
                } catch (Exception err)
                {
                    throw err;
                }
            }
        }
Ejemplo n.º 16
0
    /// <summary>
    /// Demonstrates how to perform a login and a logout
    /// using the default feature.
    /// </summary>
    public void LoginLogoutDefaultDemo()
    {
        HaspFeature feature = HaspFeature.Default;


        Hasp hasp = new Hasp(feature);

        HaspStatus status = hasp.Login(VendorCode.Code, scope);

        ReportStatus(status);

        if (HaspStatus.StatusOk == status)
        {
            status = hasp.Logout();

            ReportStatus(status);
        }

        // recommended, but not mandatory
        // this call ensures that all resources to the key
        // are freed immediately.
        hasp.Dispose();
    }
Ejemplo n.º 17
0
        private static void InitializeLicense()
        {
            // Must change by released program
            ProgramLicense = new NKHardLockInfo()
            {
                VendorCode = NKLicenseList.Code_YIOBI,
                Feature    = (int)NKLicenseList.Feature_YIOBI.NK_Label,
                Scope      = NKLicenseList.DefaultScope,

                HaspID        = string.Empty,
                NetCountLimit = string.Empty,
                MaxMemory     = (int)NKLicenseList.MaxMemory.SRM_PRO,
                MemoryType    = NKLicenseList.MemoryType.ePM_Ex,

                ManufacturedDate      = new DateTime(),
                ServiceExpirationDate = new DateTime(),
            };
            //

            HaspFeature feature = HaspFeature.FromFeature(ProgramLicense.Feature);

            HaspData = new Hasp(feature);
        }
Ejemplo n.º 18
0
    //public void Init()
    //{
    //    InitDog();
    //    //InvokeRepeating("CheckOutDog",10,300);
    //}

    //加密狗初始化//
    public void  InitDog()
    {
        if (ioo.gameController.Type == InputType.Mouse)
        {
            return;
        }

        haspDemo = new HaspDemo();
        hasp     = haspDemo.LoginDemo(HaspFeature.FromFeature(FeatureID));

        if (hasp == null || !hasp.IsLoggedIn())
        {
            Application.Quit();
            Debug.Log("登录加密狗失败!!!");
            return;
        }
        //haspDemo.WriteMessageFirst(hasp, HaspFileId.ReadWrite, "");
        device = SystemInfo.deviceUniqueIdentifier;
        //每次开启游戏时随机向加密狗中写入一个数字,防止监听及共享打印机破解加密狗\\
        long index = (long)UnityEngine.Random.Range(1000000000, 99999999999999);

        checkIndex = index.ToString();

        readStrs = haspDemo.ReadToStr(hasp, HaspFileId.ReadWrite);
        if (GetDeviceStr(readStrs) == "")
        {
            writeStrs += device;
        }
        else
        {
            writeStrs += GetDeviceStr(readStrs);
        }
        writeStrs += ",";
        writeStrs += checkIndex;

        haspDemo.WriteMessageFirst(hasp, HaspFileId.ReadWrite, writeStrs);
    }
Ejemplo n.º 19
0
        /// <summary>
        /// 打开加密狗
        /// </summary>
        /// <param name="tz">厂商</param>
        /// <param name="pwr">天数</param>
        /// <param name="er">错误代码</param>
        /// <returns></returns>
        public HaspStatus ClassCS(int tz, out int leftDays, out int er)
        {
            leftDays = -1;

            er = -1;

            try
            {
                string pwr = string.Empty;

                scope = defaultScope;

                HaspFeature feature = HaspFeature.FromFeature(tz);

                hasp = new Hasp(feature);

                HaspStatus status = hasp.Login(strVendorCode, scope);

                if (status != HaspStatus.StatusOk)
                {
                    pwr = "0";

                    er = (int)status;

                    return(status);
                }

                DateTime time3 = new DateTime();


                hasp.GetRtc(ref time3);
                int      len   = 10;
                byte[]   bytes = new byte[len];
                HaspFile file  = hasp.GetFile(HaspFileId.ReadWrite);
                status = file.Read(bytes, 0, bytes.Length);
                pwr    = System.Text.Encoding.UTF8.GetString(bytes);
                pwr    = pwr.Replace("\0", "");

                DateTime dtStart = TimeZone.CurrentTimeZone.ToLocalTime(new DateTime(1970, 1, 1));
                long     lTime   = long.Parse(pwr);

                TimeSpan toNow    = new TimeSpan(lTime);
                DateTime dtResult = dtStart.Add(toNow);

                int dayTime = (int)(Convert.ToInt32(pwr) / 3600 / 24);

                DateTime time4 = dtResult.AddDays(dayTime);

                TimeSpan sp = time4.Subtract(time3);

                leftDays = sp.Days;

                er = (int)status;

                return(status);
            }
            catch (Exception)
            {
                return(HaspStatus.SystemError);
            }
        }
Ejemplo n.º 20
0
        /// <summary>
        /// 返回天数
        /// </summary>
        /// <param name="tz">厂商</param>
        /// <param name="pwr">激活码</param>
        /// <param name="day">天数</param>
        /// <returns></returns>
        public HaspStatus ActivationTime(int tz, string pwr, out int day)
        {
            scope = defaultScope;

            HaspFeature feature = HaspFeature.FromFeature(tz);

            hasp = new Hasp(feature);

            HaspStatus status = hasp.Login(strVendorCode, scope);

            if (pwr.Length != 16)
            {
                status = HaspStatus.TimeError;
                day    = 0;
                return(status);
            }
            if (status != HaspStatus.StatusOk)
            {
                day = 0;
                return(status);
            }

            DateTime time = new DateTime();

            hasp.GetRtc(ref time);

            HaspFile file = hasp.GetFile(HaspFileId.ReadWrite);

            byte[] _bytes = new byte[16];

            DateTime dtStart = TimeZone.CurrentTimeZone.ToLocalTime(new DateTime(1970, 1, 1));

            if (pwr.Contains("6216"))
            {
                String[] arr   = new String[5];
                byte[]   bytes = new byte[80];
                file.FilePos = 16;
                status       = file.Read(bytes, 0, bytes.Length);
                string _pwr = System.Text.Encoding.UTF8.GetString(bytes);

                for (int i = 0; i < arr.Length; i++)
                {
                    arr[i] = _pwr.Substring(i * 16, 16);
                    if (pwr.Equals(arr[i]))
                    {
                        file.FilePos = (16 * i) + 16;
                        Thread.Sleep(10);
                        status = file.Write(_bytes, 0, _bytes.Length);

                        DateTime time3 = time.AddDays(30);

                        long time2 = (long)(time3 - dtStart).TotalSeconds;

                        string _time = time2.ToString();

                        byte[] decoded = System.Text.Encoding.UTF8.GetBytes(_time);

                        file.FilePos = 0;

                        status = file.Write(decoded, 0, decoded.Length);

                        day = 30;

                        return(status);
                    }
                }
            }
            else if (pwr.Contains("6217"))
            {
                byte[] bytes = new byte[80];
                file.FilePos = 96;
                status       = file.Read(bytes, 0, bytes.Length);
                string _pwr = System.Text.Encoding.UTF8.GetString(bytes);


                String[] arr = new String[5];
                for (int i = 0; i < arr.Length; i++)
                {
                    arr[i] = _pwr.Substring(i * 16, 16);

                    if (pwr.Equals(arr[i]))
                    {
                        file.FilePos = (16 * i) + 96;
                        Thread.Sleep(10);
                        status = file.Write(_bytes, 0, _bytes.Length);

                        DateTime time3 = time.AddDays(60);

                        long time2 = (long)(time3 - dtStart).TotalSeconds;

                        string _time = time2.ToString();

                        byte[] decoded = System.Text.Encoding.UTF8.GetBytes(_time);

                        file.FilePos = 0;

                        status = file.Write(decoded, 0, decoded.Length);

                        day = 60;

                        return(status);
                    }
                }
            }
            else if (pwr.Contains("6218"))
            {
                byte[] bytes = new byte[80];
                file.FilePos = 176;
                status       = file.Read(bytes, 0, bytes.Length);

                string _pwr = System.Text.Encoding.UTF8.GetString(bytes);


                String[] arr = new String[8];
                for (int i = 0; i < arr.Length; i++)
                {
                    arr[i] = _pwr.Substring(i * 16, 16);

                    if (pwr.Equals(arr[i]))
                    {
                        file.FilePos = (16 * i) + 176;
                        Thread.Sleep(10);
                        status = file.Write(_bytes, 0, _bytes.Length);

                        DateTime time3 = time.AddDays(90);

                        long time2 = (long)(time3 - dtStart).TotalSeconds;

                        string _time = time2.ToString();

                        byte[] decoded = System.Text.Encoding.UTF8.GetBytes(_time);

                        file.FilePos = 0;
                        status       = file.Write(decoded, 0, decoded.Length);

                        day = 90;

                        return(status);
                    }
                }
            }
            else if (pwr.Contains("6219"))
            {
                byte[] bytes = new byte[16];
                file.FilePos = 256;
                status       = file.Read(bytes, 0, bytes.Length);

                string _pwr = System.Text.Encoding.UTF8.GetString(bytes);


                String[] arr = new String[1];
                for (int i = 0; i < arr.Length; i++)
                {
                    arr[i] = _pwr.Substring(i * 16, 16);

                    if (pwr.Equals(arr[i]))
                    {
                        DateTime time3 = time.AddDays(999);

                        long time2 = (long)(time3 - dtStart).TotalSeconds;

                        string _time = time2.ToString();

                        byte[] decoded = System.Text.Encoding.UTF8.GetBytes(_time);

                        file.FilePos = 0;
                        status       = file.Write(decoded, 0, decoded.Length);

                        day = 999;

                        return(status);
                    }
                }
            }
            else
            {
                status = HaspStatus.TimeError;
                day    = 0;
                return(status);
            }

            status = HaspStatus.SystemError;
            day    = 0;
            return(status);
        }
Ejemplo n.º 21
0
    public void  CheckOutDog()
    {
        if (ioo.gameController.Type == InputType.Mouse)
        {
            return;
        }

        hasp = haspDemo.LoginDemo(HaspFeature.FromFeature(FeatureID));
        if (hasp == null || !hasp.IsLoggedIn())
        {
            Application.Quit();
            Debug.Log("登录加密狗失败!!!");
            return;
        }
        readStrs = haspDemo.ReadToStr(hasp, HaspFileId.ReadWrite);
        string devicestr     = GetDeviceStr(readStrs);
        string checkindexStr = GetCheckIndexStr(readStrs);

        //每隔一段时间检验写入的数据是否是游戏一开始的数据//
        // Debug.Log(checkIndex + "  :  " + checkindexStr);
        //Debug.Log(device + "  :  " + devicestr);
        if (checkIndex != checkindexStr)
        {
            Application.Quit();
            Debug.Log("检验失败!!!");
            return;
        }
        if (device != devicestr)
        {
            Application.Quit();
            Debug.Log("检验失败!!!");
            return;
        }
        //DateTime time = DateTime.Now;
        //HaspStatus status = hasp.GetRtc(ref time);
        ////检验加密数据,总共120组,每个月随机其中的40组,3个月一个循环//
        //try
        //{
        //    int index = (UnityEngine.Random.Range(time.Month % 3 * 40, time.Month % 3 * 40 + 40));
        //    //Debug.Log(index+" : "+time.Month);
        //    string checkCode =VendorCode.DeCodeStrs[index];
        //    hasp.Decrypt(ref checkCode);
        //   // Debug.Log(checkCode + "  :  " + VendorCode.EncryptStrs[index]);
        //    if (checkCode != VendorCode.EncryptStrs[index])
        //    {
        //        Debug.Log("检验失败!!!");
        //        Application.Quit();
        //    }
        //}
        //catch
        //{
        //    int index = UnityEngine.Random.Range(0, VendorCode.DeCodeStrs.Length);
        //    string checkCode = VendorCode.DeCodeStrs[index];
        //    hasp.Decrypt(ref checkCode);
        //    Debug.Log(checkCode + "  :  " + VendorCode.EncryptStrs[index]);
        //    if (checkCode != VendorCode.EncryptStrs[index])
        //    {
        //        Debug.Log("检验失败!!!");
        //        Application.Quit();
        //    }
        //}
    }
Ejemplo n.º 22
0
    /// <summary>
    /// Runs the API demo.
    /// </summary>
    public void RunDemo(string scope)
    {
        try
        {
            this.scope = scope;

            Header();

            // Demonstrate the different login methods
            LoginDefaultAutoDemo();
            LoginLogoutDefaultDemo();
            LoginDisposeDemo();

            // Demonstrates how to get a list of available features
            GetInfoDemo();

            // run the API demo using the default feature
            // (ALWAYS present in every key)
            Hasp hasp = LoginDefaultDemo();
            SessionInfoDemo(hasp);
            ReadWriteDemo(hasp, HaspFileId.ReadWrite);
            ReadWritePosDemo(hasp, HaspFileId.ReadWrite);
            EncryptDecryptDemo(hasp);
            RtcDemo(hasp);

            // Accessing Dynamic memory available in Sentinel HL (Driverless configuration) Key
            ReadWriteDynamicMemory(hasp, HaspDemo.dynamicMemoryFileId);

            LogoutDemo(ref hasp);

            int[] features =
            {
                HaspFeature.FromFeature(1).Feature,
                HaspFeature.FromFeature(3).Feature,
                HaspFeature.FromFeature(42).Feature,
                HaspFeature.FromFeature(101).Feature
            };

            // run the API demo using various feature ids
            for (int index = 0; index < features.Length; index++)
            {
                hasp = LoginDemo(new HaspFeature(features[index]));
                SessionInfoDemo(hasp);
                ReadWriteDemo(hasp, HaspFileId.ReadWrite);
                ReadWritePosDemo(hasp, HaspFileId.ReadWrite);
                EncryptDecryptDemo(hasp);
                RtcDemo(hasp);
                LogoutDemo(ref hasp);
            }
            Footer();
        }
        catch (Exception ex)
        {
            //if (textHistory == null)
            //    Console.WriteLine(ex.Message);
            //else
            //    System.Windows.Forms.MessageBox.Show(ex.Message,
            //                                     "Exception",
            //                                      System.Windows.Forms.MessageBoxButtons.OK);
        }
    }