Trying to get the full path of the executable from a pid. It fails to compile no matter what I tried. g++ (MinGW.org GCC-6.3.0-1) 6.3.0
#define _WIN32_WINNT 0x0501
#include <windows.h>
#include <process.h>
#include <string>
#include <iostream>
using namespace std;
string getProcessName(unsigned long pid)
{
string name = "";
TCHAR processPath[MAX_PATH] = { 0 };
DWORD len = MAX_PATH;
HANDLE hProcess = OpenProcess( PROCESS_QUERY_INFORMATION | PROCESS_VM_READ, FALSE, pid );
int rc = GetProcessImageFileName(hProcess, processPath, len);
if(rc > 0)
{
// GET STRING HERE
}
CloseHandle(hProcess);
return name;
}
output:
..\src\Test.cpp:15:61: error: 'GetProcessImageFileName' was not declared in this scope