日期:2014-05-18 浏览次数:21064 次
private void tmrTickTimer_Tick(object sender, System.EventArgs e) { //Environment类提供有关当前环境和平台的信息以及操作它们的方法 long curTickValue = Environment.TickCount; long difference = curTickValue - compuTime; long computerHours, computerMinutes, computerSeconds; long applicationHours, applicationMinutes, applicationSeconds; //converting milliseconds into hours, minutes and seconds 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.lblComputer.Text = String.Format( "本计算机已运行了 {0} 小时 {1} 分 {2} 秒 ", computerHours.ToString(), computerMinutes.ToString(), computerSeconds.ToString()); this.lblApplication.Text = String.Format( "本应用程序已运行了 {0} 小时 {1} 分 {2} 秒 ", applicationHours.ToString(), applicationMinutes.ToString(), applicationSeconds.ToString()); }