Click to Rate and Give Feedback
MSDN
MSDN Library
System Services
 ProcessIdToSessionId Function

  Switch on low bandwidth view
ProcessIdToSessionId Function

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

Syntax

C++
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 clientWindows 2000 Professional
Minimum supported serverWindows 2000 Server
HeaderWinbase.h (include Windows.h)
LibraryKernel32.lib
DLLKernel32.dll

See Also

WTSQuerySessionInformation
OSVERSIONINFOEX

Send comments about this topic to Microsoft

Build date: 6/26/2009

Tags What's this?: Add a tag
Community Content   What is Community Content?
Add new content RSS  Annotations
Processing
© 2009 Microsoft Corporation. All rights reserved. Terms of Use  |  Trademarks  |  Privacy Statement
Page view tracker