I am currently using the following code to get the processID of every process running.
WTS_PROCESS_INFO* pWPIs = NULL;
DWORD dwProcCount = 0;
if(WTSEnumerateProcesses(WTS_CURRENT_SERVER_HANDLE, NULL, 1, &pWPIs, &dwProcCount))
{
//Go through all processes retrieved
for(DWORD i = 0; i < dwProcCount; i++)
{
//pWPIs[i].pProcessName = process file name only, no path!
//pWPIs[i].ProcessId = process ID
//pWPIs[i].SessionId = session ID, if you need to limit it to the logged in user processes
//pWPIs[i].pUserSid = user SID that started the process
}
}
//Free memory
if(pWPIs)
{
WTSFreeMemory(pWPIs);
pWPIs = NULL;
}
I would also like to get the Window title to each of these processes if they have one. I am only interested in the process in my current session so I will filter out all processes based on session ID. If they are my session then I would like to get the Window Title.
So for example, if I ran this code with 10 notepads open I would see
notepad.exe
notepad.exe
notepad.exe
notepad.exe
notepad.exe
notepad.exe
...
But I want to get the title so that I know which notepad has which file open.