在窗体中建一个 DateTime 变量,在窗体的 Load 事件中将 DateTime.Now 保存在此变量中,以后随用随取。

解决方案 »

  1.   

    using System.Diagnostics;ProProcess current = Process.GetCurrentProcess(); 
    //获取win form应用程序已经启动的时间
    //current.StartTime
    //current.TotalProcessorTime
    //current.UserProcessorTime
      

  2.   

    System.Diagnostics.Process pr=System.Diagnostics.Process.GetCurrentProcess();
    System.TimeSpan Ts=DateTime.Now.Subtract(pr.StartTime);
    textBox1.Text=Ts.ToString();
      

  3.   

    大象的方法是我采用的,但我以为C#同Vc一个有一个类似Get...Count的方法,可以直接获取启动运行的时间,Knight94(愚翁) 的方法也有问题,只是CPU耗用时间,所以也没有得到运行时间。