3 #include <winpr/error.h>
4 #include <winpr/wtsapi.h>
5 #include <winpr/environment.h>
7 int TestWtsApiEnumerateProcesses(
int argc,
char* argv[])
11 HANDLE hServer = NULL;
18 if (!GetEnvironmentVariableA(
"WTSAPI_LIBRARY", NULL, 0))
20 printf(
"%s: No RDS environment detected, skipping test\n", __func__);
25 hServer = WTS_CURRENT_SERVER_HANDLE;
30 bSuccess = WTSEnumerateProcessesA(hServer, 0, 1, &pProcessInfo, &count);
34 printf(
"WTSEnumerateProcesses failed: %" PRIu32
"\n", GetLastError());
40 printf(
"WTSEnumerateProcesses enumerated %"PRIu32
" processs:\n", count);
41 for (DWORD i = 0; i < count; i++)
42 printf(
"\t[%"PRIu32
"]: %s (%"PRIu32
")\n", i, pProcessInfo[i].pProcessName, pProcessInfo[i].ProcessId);
46 WTSFreeMemory(pProcessInfo);