In some application we need to find the status of system, wether its in idle or non idle.
the folllowing code will help u to find the system status. This code give time since last
input from both mouse and keyboard.
#define _WIN32_WINNT 0x501
#include <windows.h>
#include <stdio.h>
#include <conio.h>
void main()
{
int totaltime;
LASTINPUTINFO info;
info.cbSize = sizeof(LASTINPUTINFO);
do
{
totaltime = GetTickCount();
GetLastInputInfo(&info);
printf("idletime %d\n",(totaltime - info.dwTime)/1000);
}
while(((totaltime - info.dwTime)/1000) < 10*60);
printf("System is idle for past %d seconds", (totaltime - info.dwTime)/1000);
getch();
}