Process Problem?

I appear to be having a problem due to the last function. It is mainly about the pe32.th32ProcessId type.

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
 #include  <iostream>
#include <windows.h>
#include <tlhelp32.h>
#include <string>
using namespace std;

string FindParent(DWORD ID);
char File[] = "BatteryLife.exe";
PROCESSENTRY32 pe32;
HANDLE hProcess;
HANDLE hProcess1;
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" << "Threads: " << pe32.cntThreads  << endl << " Parent Process: " << FindParent(pe32.th32ParentProcessID);
	}
	cin.get();
		return 0;
}
// Where the Problems mainly occure...
DWORD* FindParent(int process); {
	if (Process32First(hProcess1, &pe32)) {
	do{
	}while(Process32Next(hProcess1, &pe32));
	if (pe32.th32ProcessID==process) {
		return *pe32.szExeFile;
	}
	}}
I was able to fix it, just a problem with a curly brace messed it up entirely...
As well as some other minor errors such as the return type.
Last edited on
Topic archived. No new replies allowed.