This topic has not yet been rated - Rate this topic

WTSEnumerateServers function

Applies to: desktop apps only

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

Syntax

BOOL WTSEnumerateServers(
  __in  LPTSTR pDomainName,
  __in  DWORD Reserved,
  __in  DWORD Version,
  PWTS_SERVER_INFO *ppServerInfo,
  DWORD *pCount
);

Parameters

pDomainName [in]

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.

Reserved [in]

Reserved. The value of this parameter must be 0.

Version [in]

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

ppServerInfo

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.

pCount

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.

Remarks

This function will not work if NetBT is disabled.

Requirements

Minimum supported client

Windows 2000 Professional

Minimum supported server

Windows 2000 Server

Header

Wtsapi32.h

Library

Wtsapi32.lib

DLL

Wtsapi32.dll

Unicode and ANSI names

WTSEnumerateServersW (Unicode) and WTSEnumerateServersA (ANSI)

See also

WTS_SERVER_INFO

 

 

Send comments about this topic to Microsoft

Build date: 3/7/2012

Did you find this helpful?
(1500 characters remaining)
Community Content Add
Annotations FAQ
WTSEnumerateServers Function not working in Windows 2008 domain
Note the comment in this tech article: "This function will not work if NetBT is disabled."

The WTSEnumerateServers function was no longer working in Windows 2008. The WTSEnumerateServers function relies on NETBIOS to be functional in the domain. Windows 2008 server disables the computer browser service on the DC by default now, so Netbios is rendered useless. Enabling the computer browser service on the DC only will return full functionality of the WTSAPI functions. This is a great fix, but as Microsoft have said that they will no longer support Netbios in the future, I’m sure we’ll have to revise our development strategy in TS environment. For the record as well, those that use the NETSERVEREnum function to do the same as WTSEnumerateServers, this also requires the Computer Browser Service to be enabled on a Windows 2008 DC.