日期:2014-05-18  浏览次数:21064 次

在ToolStripStatusLabel上显示程序运行时间。
额,如题,我要在ToolStripStatusLabel上显示程序已经运行了多久了,要能会加的。。代码要怎么写啊?
  一打开 时间是0天0时0分0秒, 然后慢慢加。。。。

------解决方案--------------------
C# code
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()); 

}