簡體   English   中英

如何獲得啟動正在運行的進程的時間?

[英]How do I get time of launch of a running process?

我正在嘗試啟動運行進程的時間。 是否可以在Windows中進行操作,請問如何?

您可以使用GetProcessTimes()函數。 使用GetCurrentProcess()獲取當前進程的句柄。

它的參數之一( lpCreationTime )是指向FILETIME結構的指針,該結構將用創建進程的時間來填充。

然后,您可以使用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.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM