软件试用期设置

1.第一次窗体显示前发生:

1   public FrmMain()
2         {
3             InitializeComponent();
4             Load += FrmMain_Load;
5           }

2.主窗体Load事件

 1   private void FrmMain_Load(object sender, EventArgs e)
 2         {                     
 3             try
 4             {
 5                 DateTime usetime = Convert.ToDateTime("xxxx/xx/xx 00:00:00");
 6                 DateTime daytime = DateTime.Parse(System.DateTime.Now.ToLongDateString());
 7                 TimeSpan ts = usetime - daytime;
 8                 int day = ts.Days;
 9                 if (day <= 0)
10                 {
11                     if (MessageBox.Show("软件试用期已到,请注册后再使用!", "提示", MessageBoxButtons.OK) == DialogResult.OK)
12                     {
13                         Application.Exit();
14                     }
15                 }
16                 else
17                 {
18                   //执行Load的代码
19                 }
20             }
21             catch { }           
22         }

 

posted @ 2019-01-02 11:27  Bonnie_W  阅读(581)  评论(0编辑  收藏  举报