如何在当前进程启动时获取DateTime?
The StartTime
property on the Process
type is returning that value:
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.
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
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.