Export (0) Print
Expand All
Expand Minimize

WTSEnumerateSessions function

Retrieves a list of sessions on a Remote Desktop Session Host (RD Session Host) server.

Syntax


BOOL WTSEnumerateSessions(
  _In_  HANDLE            hServer,
  _In_  DWORD             Reserved,
  _In_  DWORD             Version,
  _Out_ PWTS_SESSION_INFO *ppSessionInfo,
  _Out_ DWORD             *pCount
);

Parameters

hServer [in]

A handle to the RD Session Host server.

Note  You can use the WTSOpenServer or WTSOpenServerEx functions to retrieve a handle to a specific server, or WTS_CURRENT_SERVER_HANDLE to use the RD Session Host server that hosts your application.
Reserved [in]

This parameter is reserved. It must be zero.

Version [in]

The version of the enumeration request. This parameter must be 1.

ppSessionInfo [out]

A pointer to an array of WTS_SESSION_INFO structures that represent the retrieved sessions. To free the returned buffer, call the WTSFreeMemory function.

Session permissions:  

  • To enumerate a session, you must enable the query information permission. For more information, see Remote Desktop Services Permissions.
  • To change permissions on a session, use the Remote Desktop Services Configuration administrative tool.
  • To enumerate sessions running on a virtual machine hosted on a RD Virtualization Host server, you must be a member of the Administrators group on the RD Virtualization Host server.
pCount [out]

A pointer to the number of WTS_SESSION_INFO structures returned in the ppSessionInfo parameter.

Return value

Returns zero if this function fails. If this function succeeds, a nonzero value is returned.

To get extended error information, call GetLastError.

Requirements

Minimum supported client

Windows Vista

Minimum supported server

Windows Server 2003

Header

Wtsapi32.h

Library

Wtsapi32.lib

DLL

Wtsapi32.dll

Unicode and ANSI names

WTSEnumerateSessionsW (Unicode) and WTSEnumerateSessionsA (ANSI)

See also

WTS_SESSION_INFO

 

 

Show:
© 2015 Microsoft