function GetProcessSessionId(const hProcess: THandle): ULONG; stdcall; // Determines the session identifier (ID) of the target process var dwSessionId: DWORD; begin dwSessionId := GetProcessSessionId(GetCurrentProcess()); ShowMessage(Format('My current process Session Id is %u', [dwSessionId])); end;