[英]How do I correctly launch a process and forward stdin/stdout/stderr?
[英]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.