WTS_TYPE_CLASS enumeration the first parameter of the WTSFreeMemoryEx function has an enum type definition.
Code:
typedef enum {
WTSTypeProcessInfoLevel0,
WTSTypeProcessInfoLevel1,
WTSTypeSessionInfoLevel1
} WTS_TYPE_CLASS;
Code:
BOOL WINAPI WTSFreeMemoryEx(
_In_ WTS_TYPE_CLASS WTSTypeClass,
_In_ PVOID pMemory,
_In_ ULONG NumberOfEntries
);
I dont know how to use an enum definition. This is how far I got but I dont think its good:
Code:
#include <windows.h>
#include <Wtsapi32.h>
#include <iostream>
#include <string>
using namespace std;
int main()
{
WTS_PROCESS_INFO_EX* pWPIs = NULL;
LPTSTR *ppProcessInfo;
DWORD dwProcCount = 0;
DWORD pLevel = 1;
if(WTSEnumerateProcessesEx(WTS_CURRENT_SERVER_HANDLE,
&pLevel,
1,
(LPSTR*)&pWPIs,
&dwProcCount))
{
//Go through all processes retrieved
for(DWORD i = 0; i < dwProcCount; i++)
{
printf("%2d. %-27s pid: %u - %i\n",
i, pWPIs[i].pProcessName, pWPIs[i].ProcessId, pWPIs[i].NumberOfThreads);
}
}
else
{
cout << "WTSEnumerateProcesses failed!\n\n";
return -1;
}
// Free memory
WTS_TYPE_CLASS WTS = {0};
WTS wts;
wts.WTSTypeProcessInfoLevel1 = 1;
if(pWPIs)
{
WTSFreeMemoryEx(wts, pWPIs, dwProcCount);
pWPIs = NULL;
}
return 0;
}