WTSEnumerateProcessesExW function

Retrieves information about the active processes on the specified Remote Desktop Session Host (RD Session Host) server or Remote Desktop Virtualization Host (RD Virtualization Host) server.

Syntax

BOOL WTSEnumerateProcessesExW(
  HANDLE hServer,
  DWORD  *pLevel,
  DWORD  SessionId,
  LPWSTR *ppProcessInfo,
  DWORD  *pCount
);

Parameters

hServer

A handle to an RD Session Host server. Specify a handle opened by the WTSOpenServer function, or specify WTS_CURRENT_SERVER_HANDLE to indicate the server on which your application is running.

pLevel

A pointer to a DWORD variable that, on input, specifies the type of information to return. To return an array of WTS_PROCESS_INFO structures, specify zero. To return an array of WTS_PROCESS_INFO_EX structures, specify one.

If you do not specify a valid value for this parameter, on output, WTSEnumerateProcessesEx sets this parameter to one and returns an error. Otherwise, on output, WTSEnumerateProcessesEx does not change the value of this parameter.

SessionId

The session for which to enumerate processes. To enumerate processes for all sessions on the server, specify WTS_ANY_SESSION.

ppProcessInfo

A pointer to a variable that receives a pointer to an array of WTS_PROCESS_INFO or WTS_PROCESS_INFO_EX structures. The type of structure is determined by the value passed to the pLevel parameter. Each structure in the array contains information about an active process. When you have finished using the array, free it by calling the WTSFreeMemoryEx function. You should also set the pointer to NULL.

pCount

A pointer to a variable that receives the number of
structures returned in the buffer referenced by the ppProcessInfo 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 the GetLastError function.

Remarks

The caller must be a member of the Administrators group to enumerate processes that are running under another user session.

Requirements

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

See Also

WTSOpenServer

WTS_PROCESS_INFO

WTS_PROCESS_INFO_EX