近来,由于面对屏幕时间过长,眼睛很是不舒服,想写个自动提示工作时间的服务程序来提醒自己.于是上网搜索一通,找到了一位仁兄写的03代码,移植下,就这样的剽窃了他的成果,在此先谢过了.不要追究责任哦.其实很简单的一个服务程序.就是隔一小时弹出个信息框告诫下自己要注意休息下.大概步骤是:创建一个WINDOWS服务程序,命名为:EyeService.引用下 System.Windows.Forms;用以弹出信息框.再using System.Threading;即可.源代码如下:
 1眼睛保护程序using System;
 2眼睛保护程序using System.Collections.Generic;
 3眼睛保护程序using System.ComponentModel;
 4眼睛保护程序using System.Data;
 5眼睛保护程序using System.Diagnostics;
 6眼睛保护程序using System.ServiceProcess;
 7眼睛保护程序using System.Text;
 8眼睛保护程序using System.Windows.Forms;
 9眼睛保护程序using System.Threading;
10眼睛保护程序
11眼睛保护程序namespace EyeService
12
添加安装程序,将serviceInstaller1启动类型改为:Automatic以便开机即运行此服务.其他属性根据个人爱好更改即可.最后安装下此服务后,在控制面板的服务列表中就可以看到了.
眼睛保护程序
运行一小时后弹出信息框:
眼睛保护程序

相关文章: