Skip to content

Latest commit

 

History

History
118 lines (83 loc) · 5.55 KB

nf-wtsapi32-wtsenumeratesessionsexa.md

File metadata and controls

118 lines (83 loc) · 5.55 KB
UID title description helpviewer_keywords old-location tech.root ms.assetid ms.date ms.keywords req.header req.include-header req.target-type req.target-min-winverclnt req.target-min-winversvr req.kmdf-ver req.umdf-ver req.ddi-compliance req.unicode-ansi req.idl req.max-support req.namespace req.assembly req.type-library req.lib req.dll req.irql targetos req.typenames req.redist ms.custom f1_keywords dev_langs topic_type api_type api_location api_name req.apiset
NF:wtsapi32.WTSEnumerateSessionsExA
WTSEnumerateSessionsExA function (wtsapi32.h)
Retrieves a list of sessions on a specified Remote Desktop Session Host (RD Session Host) server or Remote Desktop Virtualization Host (RD Virtualization Host) server. (ANSI)
WTSEnumerateSessionsExA
wtsapi32/WTSEnumerateSessionsExA
termserv\wtsenumeratesessionsex.htm
TermServ
b903cf07-d3bd-4b65-9e57-88d9e1f74e0b
12/05/2018
WTSEnumerateSessionsEx, WTSEnumerateSessionsEx function [Remote Desktop Services], WTSEnumerateSessionsExA, WTSEnumerateSessionsExW, termserv.wtsenumeratesessionsex, wtsapi32/WTSEnumerateSessionsEx, wtsapi32/WTSEnumerateSessionsExA, wtsapi32/WTSEnumerateSessionsExW
wtsapi32.h
Windows
Windows 7
Windows Server 2008 R2
WTSEnumerateSessionsExW (Unicode) and WTSEnumerateSessionsExA (ANSI)
Wtsapi32.lib
Wtsapi32.dll
Windows
19H1
WTSEnumerateSessionsExA
wtsapi32/WTSEnumerateSessionsExA
c++
APIRef
kbSyntax
DllExport
Wtsapi32.dll
Ext-MS-Win-Session-WtsApi32-l1-1-0.dll
WTSEnumerateSessionsEx
WTSEnumerateSessionsExA
WTSEnumerateSessionsExW
ext-ms-win-session-wtsapi32-l1-1-0 (introduced in Windows 8)

WTSEnumerateSessionsExA function

-description

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

-parameters

-param hServer [in]

A handle to the target server. Specify a handle returned by the WTSOpenServer or WTSOpenServerEx function. To enumerate sessions on the RD Session Host server on which the application is running, specify WTS_CURRENT_SERVER_HANDLE.

-param pLevel [in, out]

This parameter is reserved. Always set this parameter to one. On output, WTSEnumerateSessionsEx does not change the value of this parameter.

-param Filter [in]

This parameter is reserved. Always set this parameter to zero.

-param ppSessionInfo [out]

A pointer to a PWTS_SESSION_INFO_1 variable that receives a pointer to an array of WTS_SESSION_INFO_1 structures. Each structure in the array contains information about a session on the specified RD Session Host server. If you obtained a handle to an RD Virtualization Host server by calling the WTSOpenServerEx function, the array contains information about sessions on virtual machines on the server. When you have finished using the array, free it by calling the WTSFreeMemoryEx function. You should also set the pointer to NULL.

-param pCount [out]

A pointer to a DWORD variable that receives the number of WTS_SESSION_INFO_1 structures returned in the ppSessionInfo buffer.

-returns

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 the GetLastError function.

-remarks

To obtain information about sessions running on virtual machines on an RD Virtualization Host server, you must obtain the handle by calling the WTSOpenServerEx function. To free the returned buffer, call the WTSFreeMemoryEx function and set the WTSClassType parameter to WTSTypeSessionInfoLevel1.

To enumerate a session, you need to have the Query Information permission for that session. For more information, see Remote Desktop Services Permissions. To modify permissions on a session, use the Remote Desktop Services Configuration administrative tool.

To enumerate sessions running on a virtual machine hosted on an RD Virtualization Host server, you must be a member of the Administrators group on the RD Virtualization Host server.

Note

The wtsapi32.h header defines WTSEnumerateSessionsEx as an alias which automatically selects the ANSI or Unicode version of this function based on the definition of the UNICODE preprocessor constant. Mixing usage of the encoding-neutral alias with code that not encoding-neutral can lead to mismatches that result in compilation or runtime errors. For more information, see Conventions for Function Prototypes.

-see-also

WTSFreeMemoryEx

WTSOpenServerEx

WTS_SESSION_INFO_1