[英]How do I get time of launch of a running process?
I'm trying to get the time of launch of a running process. 我正在尝试启动运行进程的时间。 Is it possible to do in Windows, and how please?
是否可以在Windows中进行操作,请问如何?
You can use the GetProcessTimes() function. 您可以使用GetProcessTimes()函数。 Use GetCurrentProcess() to get a handle to the current process.
使用GetCurrentProcess()获取当前进程的句柄。
One of its arguments ( lpCreationTime
) is a pointer to a FILETIME
struct which gets filled in with the time the process was created. 它的参数之一(
lpCreationTime
)是指向FILETIME
结构的指针,该结构将用创建进程的时间来填充。
You can then use FileTimeToSystemTime() to convert the FILETIME
struct to a SYSTEMTIME
struct which has calendar day/month/year and hour/minute/second fields. 然后,您可以使用FileTimeToSystemTime()将
FILETIME
结构转换为具有日历日/月/年和时/分/秒字段的SYSTEMTIME
结构。
HANDLE hCurrentProcess = GetCurrentProcess();
FILETIME creationTime;
FILETIME exitTime;
FILETIME kernelTime;
FILETIME userTime;
GetProcessTimes(hCurrentProcess, &creationTime,
&exitTime, &kernelTime, &userTime);
SYSTEMTIME systemTime;
FileTimeToSystemTime(&creationTime, &systemTime);
// systemTime now holds the calendar date/time the
// current process was created
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.