GetPhysicalSessionId()

Example Code

function GetPhysicalSessionId: ULONG; stdcall; { Returns the session id of the active session that has control of the physical screen and keyboard input } procedure TForm1.FormCreate(Sender: TObject); begin if GetProcessSessionId(GetCurrentProcess()) = GetPhysicalSessionId() then MessageBox(0, 'Our current session has physical control of the screen and keyboard', 'GetPhysicalSessionId', (MB_ICONINFORMATION or MB_SETFOREGROUND or MB_TOPMOST)); end;