I'm making a program that lists all running processes and gets the handle to the process using OpenProcess() and I had a few questions. I made a struct called Proc that looks like this:
Code:
class Proc
{
public:
HANDLE hproc;
PROCESSENTRY32 proc;
Proc(){ hSnap = NULL; }
};
I know it's not the coolest thing in the world, but it helped me organize the crap alot. Then I declare an array of Procs. Because I need to CloseHandle() for each OpenProcess() that I have, would it work if I did something like this:
Code:
Proc allProcs[256];
...
allProcs[i].hproc = OpenProcess(PROCESS_ALL_ACCESS, TRUE, allProcs[i].proc.th32ProcessID;
...
CloseHandle(allProcs); // no matter how many processes I open, would this close all of them? This could minimize some code if it worked, but I could get around it.
Thanks for your answers
chreez
oh, btw, can a HANDLE and a HWND sometimes be interchangeable?