[英]How to get the DateTime when the current process started?
如何在当前进程启动时获取DateTime?
The StartTime
property on the Process
type is returning that value: Process
类型的StartTime
属性返回该值:
Process.GetCurrentProcess().StartTime
This can of course be used to pick up the start time of other processes as well: 这当然可以用来获取其他进程的开始时间:
Process p = Process.GetProcessesByName("Notepad").FirstOrDefault();
if (p != null)
{
Console.WriteLine(p.StartTime);
}
You will need the Process Class found in System.Diagnostics. 您将需要System.Diagnostics中找到的Process Class。
using System.Diagnostics;
then a function like this will suffice. 那么像这样的函数就足够了。
public DateTime GetStartTime()
{
return Process.GetCurrentProcess().StartTime;
}
我认为你需要的是Process.StartTime 。
I think we can also 我想我们也可以
static DateTime startTime = DateTime.Now;
As someone posted and then deleted 有人发布然后删除
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.