Process Name not Outputed?
I appear to be having a strange problem, when I run the program, nothing gets outputed, could someone possibly help with this error?
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34
|
#include <iostream>
#include <windows.h>
#include <tlhelp32.h>
#include <string>
using namespace std;
char File[] = "BatteryLife.exe";
PROCESSENTRY32 pe32;
HANDLE hProcess;
HANDLE hProcess1;
LPVOID FindParent(DWORD process) {
if (Process32First(hProcess1, &pe32)) {
do{
}while(Process32Next(hProcess1, &pe32));
if (pe32.th32ProcessID==process) {
return pe32.szExeFile;
}
}}
int main() {
hProcess1 = CreateToolhelp32Snapshot(TH32CS_SNAPPROCESS,0);
if (Process32First(hProcess1, &pe32)) {
do{
}while(Process32Next(hProcess1, &pe32));
if (strcmp(pe32.szExeFile, File)) {
hProcess = OpenProcess(PROCESS_ALL_ACCESS,FALSE,pe32.th32ProcessID);
cout << pe32.szExeFile << ": " << pe32.th32ProcessID << "\n" << endl << " Parent Process: " << FindParent(pe32.th32ParentProcessID);
}}
cin.get();
return 0;
}
|
Topic archived. No new replies allowed.