Mega Code Archive

 
Categories / Delphi / System
 

Detect system idle time

Title: Detect system idle time Question: How to retrive system idle time? Answer: //This function will do tha job // function LastWork: DWord; var LInput: TLastInputInfo; begin LInput.cbSize := SizeOf(TLastInputInfo); GetLastInputInfo(LInput); Result := GetTickCount - LInput.dwTime; end; procedure TForm1.Timer1Timer(Sender: TObject); begin memo1.lines[0] := Format('System Idle since %d ms', [LastWork]); end;