WTSEnumerateServersA function (wtsapi32.h)

Returns a list of all Remote Desktop Session Host (RD Session Host) servers within the specified domain.


BOOL WTSEnumerateServersA(
  [in] LPSTR             pDomainName,
  [in] DWORD             Reserved,
  [in] DWORD             Version,
       PWTS_SERVER_INFOA *ppServerInfo,
       DWORD             *pCount


[in] pDomainName

Pointer to the name of the domain to be queried. If the value of this parameter is NULL, the specified domain is the current domain.

[in] Reserved

Reserved. The value of this parameter must be 0.

[in] Version

Version of the enumeration request. The value of the parameter must be 1.


Points to an array of WTS_SERVER_INFO structures, which contains the returned results of the enumeration. After use, the memory used by this buffer should be freed by calling WTSFreeMemory.


Pointer to a variable that receives the number of WTS_SERVER_INFO structures returned in the ppServerInfo buffer.

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.


This function will not work if NetBT is disabled.


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


Minimum supported client Windows Vista
Minimum supported server Windows Server 2008
Target Platform Windows
Header wtsapi32.h
Library Wtsapi32.lib
DLL Wtsapi32.dll

See also