Somebody
Somebody

Reputation: 733

Delphi : Get active user idle time from Service

i'm using this code to get the local idle time from Windows Application but when i use it on Service it not returning the active user idle time

function IdleTime: DWord;
var
  LastInput: TLastInputInfo;
begin
  LastInput.cbSize := SizeOf(TLastInputInfo);
  GetLastInputInfo(LastInput);
  Result := (GetTickCount - LastInput.dwTime) DIV 1000;
end;

any idea ?

thanks in advance

Upvotes: 1

Views: 1236

Answers (1)

David Heffernan
David Heffernan

Reputation: 612794

Your service runs in a non-interactive desktop in session 0, and so does not have access to information about interactive desktops.

You would need to run a process in an interactive desktop to get that information. And I suppose you could then pass it to your service using an IPC mechanism. Quite what you would do with the information even if you could get at it session 0 I'm not sure. Sessions are isolated.

Upvotes: 2

Related Questions