Jay0951
Jay0951

Reputation: 3

Can't get Start Time of a process

I'm trying to get the Start Time of a running process on Windows. I did some searching and a couple of people suggested getting the Creation Time of a process with GetProcessTimes() but this doesn't seem to return accurate information. After converting the time to systemtime, it seems to return 23 for the hour instead of the correct time. How do I get the correct time? Surely there has to be a way if Process Explorer can do it.

// Returns the wrong time
SYSTEMTIME ftime;
FILETIME creationTime;
GetProcessTimes(hProcess, &creationTime, &exitTime, &kernelTime, &userTime);
FileTimeToSystemTime(&creationTime, &ftime);

Upvotes: 0

Views: 254

Answers (1)

DeducibleSteak
DeducibleSteak

Reputation: 1498

FileTimeToSystemTime() gets the time in UTC time. 23 is the right answer for another 10 minutes :)

You can use SystemTimeToTzSpecificLocalTime() to convert the UTC time to the local time zone (by passing NULL as the first parameter), or to any other time zone you want.

Upvotes: 2

Related Questions