Originally Posted by
rags_to_riches
A little more investigation on your part, after copying and pasting the MSDN example, would have perhaps led you
here, where it states:
So you need to modify the MSDN sample code accordingly.
Thanks for the response; and I apologize for my lack of reseach. Below is what I have currently.
I've also tried setting the value of dwFilterFlag to 0x02, LIST_MODULES_64BIT & LIST_MODULES_ALL. None of which have changed the output: it still can only find the 32 bit processes. Are they all invalid values to assign to dwFilterFlag?
Code:
#pragma comment(lib, "Psapi.lib")
#include <windows.h>
#include <stdio.h>
#include <tchar.h>
#include <psapi.h>
void PrintProcessNameAndID( DWORD processID )
{
TCHAR szProcessName[MAX_PATH] = TEXT("<unknown>");
HANDLE hProcess = OpenProcess( PROCESS_QUERY_INFORMATION |
PROCESS_VM_READ,
FALSE, processID );
HANDLE hProc;
DWORD dwFilterFlag = 0x03;
if (NULL != hProcess )
{
HMODULE hMod;
DWORD cbNeeded;
if ( EnumProcessModulesEx( hProcess, &hMod, sizeof(hMod),
&cbNeeded, dwFilterFlag) )
{
GetModuleBaseName( hProcess, hMod, szProcessName,
sizeof(szProcessName)/sizeof(TCHAR) );
}
}
_tprintf( TEXT("%s (PID: %u).\n"), szProcessName, processID );
CloseHandle( hProcess );
}
int main()
{
DWORD aProcesses[1024], cbNeeded, cProcesses;
unsigned int i;
if ( !EnumProcesses( aProcesses, sizeof(aProcesses), &cbNeeded ) ) {
return 0;
}
cProcesses = cbNeeded / sizeof(DWORD);
for ( i = 0; i < cProcesses; i++ ) {
if( aProcesses[i] != 0 ) {
PrintProcessNameAndID( aProcesses[i] );
}
}
getchar();
return 0;
}