Пример #1
0
        //创建PCI1752更新输出及输出状态回读窗体类的实例
        /// <summary>
        /// 创建PCI1752更新输出及输出状态回读窗体类的实例
        /// 【软件作者:彭东南, [email protected]】
        /// </summary>
        /// <param name="TargetDeviceNumber">目标PCI1752设备卡号</param>
        /// <param name="DLLPassword">使用此DLL的密码</param>
        public frmPCI1752(int TargetDeviceNumber, string DLLPassword)
            {
            SuccessBuiltNew = false;
            PasswordIsCorrect = false;

            try
                {

                if (DLLPassword == "ThomasPeng" || (DLLPassword == "pengdongnan")
                    || (DLLPassword == "彭东南"))
                    {
                    PasswordIsCorrect = true;

                    if (TargetDeviceNumber < 0)
                        {
                        MessageBox.Show("'TargetDeviceNumber'设备卡号不能小于0,请改为正确参数。",
                            "参数错误");
                        return;
                        }

                    NewPCI1752 = new PCI1752(TargetDeviceNumber, "彭东南");
                    if (NewPCI1752.SuccessBuilt == false)
                        {
                        SuccessBuiltNew = false;
                        throw new Exception("Error: Failed to open the PCI1752 card: " + TargetDeviceNumber
                            + "\r\n错误:打开PCI1752卡【 " + TargetDeviceNumber + " 】 失败,请检查卡是否存在或者已经正确安装。");
                        }

                    InitializeComponent();//*********
                    if (AddCheckBoxes() == false) 
                        {
                        throw new Exception("Failed to initial the controls of form.\r\n"
                            + "初始化窗体控件失败。");
                        }
                    SuccessBuiltNew = true;
                    NeedFormControlFlag = false;

                    }
                else
                    {
                    PasswordIsCorrect = false;
                    SuccessBuiltNew = false;
                    MessageBox.Show("Right Prohibited.\return\n     You don't have the given right to use this DLL library, please contact with ThomasPeng.\r\n你未得到授权的密码,无法使用此DLL进行软件开发!请与作者彭东南联系:[email protected]\r\n                                                                版权所有: 彭东南", "", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                    return;
                    }

                }
            catch (Exception ex)
                {
                SuccessBuiltNew = false;
                MessageBox.Show("创建类的实例时出现错误!\r\n" + ex.Message, "错误", MessageBoxButtons.OK, MessageBoxIcon.Error);
                this.Dispose();
                return;
                }

            }
Пример #2
0
 //释放所有资源
 /// <summary>
 /// 释放所有资源
 /// </summary>
 private void FreeAllResource() 
     {
     try
         {
         OutputChkBoxArray = null;
         NewPCI1752.Dispose();
         NewPCI1752 = null;
         ShowTips = null;
         TempChkBox.Dispose();
         GC.Collect();
         }
     catch (Exception) 
         {
         
         }
     }