# Getting the process Kernel time



## amitbat (Dec 2, 2005)

I have a weird problem with the following code:
The first time I use SystemTimeToTzSpecificLocalTime it works fine and retrieves the process creation time, but when I use it again, for finding out the kernel time "stLocal" doesn't seem to change (the seconds and milliseconds), What am I doing wrong?
{
SYSTEMTIME stUTC, stLocal;
FILETIME pCreationTime,pExitTime,pKernelTime,pUserTime;

GetProcessTimes(
process->procinfo.hProcess,
&pCreationTime,
&pExitTime,
&pKernelTime,
&pUserTime
);


FileTimeToSystemTime(&pCreationTime, &stUTC);
SystemTimeToTzSpecificLocalTime(NULL, &stUTC, &stLocal);

//Print the date and time.
printf("%02d.%02d.%d %02d:%02d:%02d:%03d |",
stLocal.wMonth, stLocal.wDay, stLocal.wYear,
stLocal.wHour,stLocal.wMinute,stLocal.wSecond,stLocal.wMilliseconds);

FileTimeToSystemTime(&pKernelTime, &stUTC);
SystemTimeToTzSpecificLocalTime(NULL, &stUTC, &stLocal);

//Print the date and time.
printf(" %02d.%03d |",stLocal.wSecond,stLocal.wMilliseconds);


----------



## aewarnick (Sep 3, 2002)

I see one bad coding practice:
FILETIME pCreationTime,pExitTime,pKernelTime,pUserTime;
Those variables are not pointers so it is bad practice to put p before the name.

As far as your problem, I'm stumped.


----------



## lotuseclat79 (Sep 12, 2003)

amitbat said:


> I have a weird problem with the following code:
> The first time I use SystemTimeToTzSpecificLocalTime it works fine and retrieves the process creation time, but when I use it again, for finding out the kernel time "stLocal" doesn't seem to change (the seconds and milliseconds), What am I doing wrong?
> {
> SYSTEMTIME stUTC, stLocal;
> ...


Hi amitbat,

In situations like this, I like to experiment. So, what happens if you change the order of the calls, i.e. kernel time before creation time calls - or is that not possible?

-- Tom


----------

