WTSEnumerateListenersW function (wtsapi32.h)

Enumerates all the Remote Desktop Services listeners on a Remote Desktop Session Host (RD Session Host) server.

Syntax

BOOL WTSEnumerateListenersW(
  [in]            HANDLE            hServer,
  [in]            PVOID             pReserved,
  [in]            DWORD             Reserved,
  [out, optional] PWTSLISTENERNAMEW pListeners,
  [in, out]       DWORD             *pCount
);

Parameters

[in] hServer

A handle to an RD Session Host server. Always set this parameter to WTS_CURRENT_SERVER_HANDLE.

[in] pReserved

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

[in] Reserved

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

[out, optional] pListeners

A pointer to an array of WTSLISTENERNAME variables that receive the names of the listeners.

[in, out] pCount

A pointer to a DWORD variable that contains the number of listener names in the array referenced by the pListeners parameter. If the number of listener names is unknown, pass pListeners as NULL. The function will return the number of WTSLISTENERNAME variables necessary to allocate for the array pointed to by the pListeners parameter.

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

This function returns all listeners currently running on the server, including listeners that do not support Remote Desktop Protocol (RDP).

If the number of listeners is unknown, you can call this function with pListeners set to NULL. The function will then return, in the pCount parameter, the number of WTSLISTENERNAME variables necessary to receive all the listeners. Allocate the array for pListeners based on this number, and then call the function again, setting pListeners to the newly allocated array and pCount to the number returned by the first call.

Note

The wtsapi32.h header defines WTSEnumerateListeners 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.

Requirements

Requirement Value
Minimum supported client Windows 7
Minimum supported server Windows Server 2008 R2
Target Platform Windows
Header wtsapi32.h
Library Wtsapi32.lib
DLL Wtsapi32.dll