How to get title of process or process path?

  • Thread starter Thread starter BataBo Jokviu
  • Start date Start date
B

BataBo Jokviu

Guest
So as the title says Im trying to get one of those two things(process path or process title) as of right now my program only lists names and pids of the file

here is my code

#include "pch.h"
#include <iostream>
#include <windows.h>
#include "winhttp.h"
#include <tlhelp32.h>
#include <string>
#include <Wtsapi32.h>
#pragma comment(lib, "Wtsapi32.lib")
using namespace std;
#pragma comment(lib, "winhttp.lib")

int CheckForProxy();
int CheckProcesses();
std::wstring GetProcName(DWORD aPid);


int main()
{
int a = CheckForProxy();
CheckProcesses();
}

int CheckForProxy() {
[REDACTED]
}

int CheckProcesses() {
WTS_PROCESS_INFO* pWPIs = NULL;
DWORD dwProcCount = 0;
if (WTSEnumerateProcesses(WTS_CURRENT_SERVER_HANDLE, NULL, 1, &pWPIs, &dwProcCount))
{
for (DWORD i = 0; i < dwProcCount; i++)
{



std::wstring process_name = GetProcName(pWPIs.ProcessId);
}
}

if (pWPIs)
{
WTSFreeMemory(pWPIs);
pWPIs = NULL;
}
return 0;
}

std::wstring GetProcName(DWORD aPid)
{
PROCESSENTRY32 processInfo;
processInfo.dwSize = sizeof(processInfo);
HANDLE processesSnapshot = CreateToolhelp32Snapshot(TH32CS_SNAPPROCESS, NULL);

for (BOOL bok = Process32First(processesSnapshot, &processInfo);bok; bok = Process32Next(processesSnapshot, &processInfo))
{
if (aPid == processInfo.th32ProcessID)
{
CloseHandle(processesSnapshot);
return processInfo.szExeFile;
}

}
CloseHandle(processesSnapshot);
return processInfo.szExeFile;
}

Continue reading...
 
Back
Top