Reputation: 237
I'm trying to get the time of launch of a running process. Is it possible to do in Windows, and how please?
Upvotes: 0
Views: 133
Reputation: 17250
You can use the GetProcessTimes() function. Use GetCurrentProcess() to get a handle to the current process.
One of its arguments (lpCreationTime
) is a pointer to a FILETIME
struct which gets filled in with the time the process was created.
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.
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
Upvotes: 1