WTSEnumerateSessions
The WTSEnumerateSessions function retrieves a list of sessions on a specified terminal server.
BOOL WTSEnumerateSessions(
HANDLE hServer,
DWORD Reserved,
DWORD Version,
PWTS_SESSION_INFO* ppSessionInfo,
DWORD* pCount
);
Parameters
hServer
[in] Handle to a terminal server. Specify a handle opened by the WTSOpenServer function, or specify WTS_CURRENT_SERVER_HANDLE to indicate the terminal server on which your application is running.
Reserved
Reserved; must be zero.
Version
[in] Specifies the version of the enumeration request. Must be 1.
ppSessionInfo
[out] Pointer to a variable that receives a pointer to an array of WTS_SESSION_INFO structures. Each structure in the array contains information about a session on the specified terminal server. To free the returned buffer, call the WTSFreeMemory function.
To be able to enumerate a session, you need to have the Query Information permission. For more information, see Terminal Services Permissions. To modify permissions on a session, use the Terminal Services Configuration administrative tool.
pCount
[out] Pointer to the variable that receives the number of WTS_SESSION_INFO structures returned in the ppSessionInfo buffer.
Return Values
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.
Requirements
Client Requires Windows Vista, Windows XP, or Windows 2000 Professional.
Server Requires Windows Server "Longhorn", Windows Server 2003, or Windows 2000 Server.
Header
Declared in WtsApi32.h.
Library
Use WtsApi32.lib.
DLL Requires Wtsapi32.dll.
Unicode
Implemented as WTSEnumerateSessionsW (Unicode) and WTSEnumerateSessionsA (ANSI).
Partager