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

namespace WindowsApplication1
{
    public partial class Form012 : Form
    {
        private int compuTime;

        public Form012()
        {
            InitializeComponent();
        }

        private void Form012_Load(object sender, EventArgs e)
        {
            compuTime = Environment.TickCount;
        }

        private void timer1_Tick(object sender, EventArgs e)
        {
            long curTickValue = Environment.TickCount;
            long difference = curTickValue - compuTime;
            long computerHours, computerMinutes, computerSeconds;
            long applicationHours, applicationMinutes, applicationSeconds;
            //将毫秒转换成小时、分钟和秒
            computerHours = (curTickValue / (3600 * 999)) % 24;
            computerHours = (curTickValue / (3600 * 999)) % 24;
            computerMinutes = (curTickValue / (60 * 999)) % 60;
            computerSeconds = (curTickValue / 999) % 60;
            applicationHours = (difference / (3600 * 999)) % 24;
            applicationMinutes = (difference / (60 * 999)) % 60;
            applicationSeconds = (difference / 999) % 60;

            this.label1.Text = String.Format("这台计算机已经开机 {0} 小时, {1} 分钟 {2} 秒",computerHours.ToString(),computerMinutes.ToString(),computerSeconds.ToString());
            this.label2.Text = String.Format("这个程序已经运行了 {0} 小时, {1} 分钟 {2} 秒", applicationHours.ToString(),applicationMinutes.ToString(),applicationSeconds.ToString());
}

        private void button1_Click(object sender, EventArgs e)
        {
            this.Close();
        }

    }
}