软件保护程序综合设计
实验三 软件保护程序综合设计一、实验目的1掌握软件保护的基本方法;2加强软件保护应用能力;3提高编程技术。二、实验环境Pentium(R) Dual-Core 3.20GHz以上 CPU,1.96以上内存,200G以上硬盘,安装WindowsXP以上操作系统。安装vs2008等编程环境。三、实验内容与步骤 1编写一简单的加法程序,如下: private void button1_Click(object sender, EventArgs e) try int a = int.Parse(textBox1.Text); int b = int.Parse(textBox2.Text); textBox3.Text = (a + b).ToString(); catch (Exception ex) MessageBox.Show(ex.ToString(); Form1_Load(sender, e); 编写一时间时间,使之未经过序列号使用时不断跳出显示“请购买正版” 的对话框。 private void Form1_Load(object sender, EventArgs e) if (b = false) System.Timers.Timer t = new System.Timers.Timer(8000); t.Elapsed += new System.Timers.ElapsedEventHandler(Show); t.AutoReset = true; t.Enabled = true; else public void Show(object source,System.Timers.ElapsedEventArgs e) MessageBox.Show("请购买正版","消息",MessageBoxButtons.OK); 3. 编写一方法使之输入序列号与已知序列号相同时不再有对话框弹出且程序正常使用。 private void button2_Click(object sender, EventArgs e) if (this.textBox4.Text = "abc") b = true; this.button1.Text = "求和" this.label4.Visible = false; this.textBox4.Visible = false; this.label1.Visible = true; this.label2.Visible = true; this.label3.Visible = true; this.textBox1.Visible = true; this.textBox2.Visible = true; this.textBox3.Visible = true; this.button2.Visible = false; this.button1.Visible = true; else b = false; this.label4.Visible = true; this.textBox4.Visible = true; this.label1.Visible = true; this.label2.Visible = true; this.label3.Visible = true; this.textBox1.Visible = true; this.textBox2.Visible = true; this.textBox3.Visible = true; this.button2.Visible = true; this.button1.Visible = true; Form1_Load(sender, e); 四、实验体会通过本次上机实验,主要进行对软件保护的代码编写。掌握代码保护的原理,如每隔2分钟就会弹出警告窗口,提示“请购买正式版本”;使用该软件前需要输入序列号才能运行;该软件只能使用30天;程序中使用“花指令”防止破解;使用Key File保护等。由于水平和其他原因的限制,本次实验仅仅是对程序弹出警告窗口和输入序列号才能进行,这两种软件保护相对比较简单,但也容易被破解,所以还应该学习限定软件使用日期,“花指令”等软件保护,采用多种保护结合更好的保护好软件的产权。