闹铃管理程序

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;

using Microsoft.Win32;
using System.Windows;
namespace AutoRun
{
    public partial class AuntoRun : Form
    {
        public AuntoRun()
        {
            InitializeComponent();
            OPenWeb();
            string filePath=Path();
            this.Text = "公司打卡程序";

            //Clock clock = new Clock();
            //TimeArgs arg = new TimeArgs("赖虫起床......", 21);
            //clock.SetTime(arg);
        }

 

        private  void OPenWeb()
        {
            webBrowser4.Navigate("xxxxxxx");
        }

        /// <summary>
        ///  注册表些数据
        /// </summary>
        /// <param name="name">注册的键</param>
        /// <param name="tovalue">注册表中的值</param>
        private void WTRegedit(string name, string tovalue)
        {
            RegistryKey lm = Registry.LocalMachine;
            RegistryKey software = lm.CreateSubKey("AuntoRun");
           
        }
        /// <summary>
        /// 开机启动项
        /// </summary>
        /// <param name="Started">是否启动</param>
        /// <param name="name">启动值的名称</param>
        /// <param name="path">启动程序的路径</param>
        public static void RunWhenStart(bool Started, string name, string path)
        {
            RegistryKey HKLM = Registry.LocalMachine;
            RegistryKey Run = HKLM.CreateSubKey(@"SOFTWARE/Microsoft/Windows/CurrentVersion/Run");
            if (Started == true)
            {
                try
                {
                    Run.SetValue(name, path);
                    HKLM.Close();
                }
                catch
                {

                }
            }
            else
            {
                try
                {
                    Run.DeleteValue(name);
                    HKLM.Close();
                }
                catch
                {

                }
            }
        }


        private string Path()
        {
          
           string s= System.Windows.Forms.Application.StartupPath.ToString();
           return s + "AutoRun.exe";
   
        }

        private void toolStripButton1_Click(object sender, EventArgs e)
        {
            this.webBrowser4.GoBack();
        }


        class TimeArgs : EventArgs
        {
          
            //闹钟声明
            private string _Message;
            //闹铃时间
            private int _RingTime;
            //默认闹铃
            public TimeArgs()
            {
                _Message = "滴滴...滴滴...";
                _RingTime = 0;
            }
            public TimeArgs(string message, int ringtime)
            {
                this._Message = message;
                this._RingTime = ringtime;
            }
            //设置闹铃声音
            public string Message
            {
                get
                {
                    return _Message;
                }
                set
                {
                    _Message = value;
                }
            }
            //设置闹铃时间
            public int RingTime
            {
                get
                {
                    return _RingTime;
                }
                set
                {
                    _RingTime = value;
                }
            }
        }

        //闹铃代理
        delegate void RingHandler(object sender, TimeArgs e);
        class Clock
        {
            AuntoRun auntoRun = new AuntoRun();
            //闹铃事件
            private event RingHandler RingEvent;
            public Clock()
            {
                //把闹铃事件挂接到方法上
                RingEvent += new RingHandler(Clock_RingEvent);
            }
            //闹铃事件处理程序
            private void Clock_RingEvent(object sender, TimeArgs e)
            {
                //Console.WriteLine(e.Message);
            }
            //闹铃时间监测
            private void ReadyToRing(TimeArgs e)
            {
                while (true)
                {
                    System.Threading.Thread.Sleep(1000);
                    if (DateTime.Now.Minute == 39 && DateTime.Now.Second == 0)
                    {
                        //RingEvent(this, e);
                        auntoRun.webBrowser4.Navigate("xxxxxx");
                    }
                }
            }
            //设置闹铃
            public void SetTime(TimeArgs e)
            {
                ReadyToRing(e);
            }
        }
   


      
    
      
    }
}

posted @ 2011-02-17 17:46  likunran  阅读(233)  评论(0编辑  收藏  举报