Export (0) Print
Expand All
Expand Minimize

ProcessIdToSessionId function

Retrieves the Remote Desktop Services session associated with a specified process.

Syntax


BOOL ProcessIdToSessionId(
  _In_   DWORD dwProcessId,
  _Out_  DWORD *pSessionId
);

Parameters

dwProcessId [in]

Specifies a process identifier. Use the GetCurrentProcessId function to retrieve the process identifier for the current process.

pSessionId [out]

Pointer to a variable that receives the identifier of the Remote Desktop Services session under which the specified process is running. To retrieve the identifier of the session currently attached to the console, use the WTSGetActiveConsoleSessionId function.

Return value

If the function succeeds, the return value is a nonzero value.

If the function fails, the return value is zero. To get extended error information, call GetLastError.

Remarks

Callers must hold the PROCESS_QUERY_INFORMATION access right for the specified process. For more information, see Process Security and Access Rights.

Requirements

Minimum supported client

Windows XP

Minimum supported server

Windows Server 2003

Header

Winbase.h (include Windows.h)

Library

Kernel32.lib

DLL

Kernel32.dll

See also

WTSQuerySessionInformation
OSVERSIONINFOEX

 

 

Show:
© 2014 Microsoft