I used the code mentioned here to calculate the system downtime through the window service. But on Windows 7 and Vista, I always get LastInputInfo.dwTimeas zero by which I cannot calculate the system downtime. I gave an example code below.
if (GetLastInputInfo(ref LastInputInfo))
{
LastInputTicks = (int)LastInputInfo.dwTime;
IdleTicks = systemUptime - LastInputTicks;
}
When I test the same code in a Windows application, I get the correct one dwTime. I need to have the correct one dwTimein my service to calculate the correct system downtime.
Please help with some examples.
deepu source
share