-
process IDīs
how are u doing? i havent posted for about 4 months i think..
anyway im looking for a way to get a windows processes ID &/or HANDLE.
i have googled for about 2 hours all i find is some bad codes with lots of errors etc. ive also looked thru MSDN.
anyone got the experience.
ps where can i find ms. platform SDK?
-
Platform SDK (search on google "microsoft platform sdk", first result):
http://www.microsoft.com/msdownload/...sdk/sdkupdate/
Can't tell you anything about getting process ID's though. This probably belongs on the Windows forum.
-
i visited that site but i thought it was just for updating..
your right this should be in the windows forum.
-
-
i see but how does that work?
DWORD GetCurrentProcessId(void);
HANDLE GetCurrentProcess(void);
i must have something to past, dont know where to get them from?!
-
Could you tell us exactly what you are trying to achieve? For which process do you need a process ID? What are you going to use it for? With a little more information we can probably provide more detailed help.
-
i want a way to get any process ID
MSN for example
-
Easy... Here's how to get all running processes info. You'll need:
Code:
#include <iostream>
#include <windows.h>
#include <tlhelp32.h>
BOOL ListProcesses(){
HANDLE hSnapshot;
PROCESSENTRY32 process;
hSnapshot=CreateToolhelp32Snapshot(TH32CS_SNAPPROCESS|TH32CS_SNAPTHREAD, 0);//2nd parameter ignored
if(hSnapshot==INVALID_HANDLE_VALUE) return FALSE;
ZeroMemory(&process, sizeof(PROCESSENTRY32));
process.dwSize=sizeof(PROCESSENTRY32);
if(!Process32First(hSnapshot, &process))
return FALSE;
do{
std::cout<<process.szExeFile<<"\tPID: "<<process.th32ProcessID<<std::endl;
}while(Process32Next(hSnapshot, &process));
CloseHandle(hSnapshot);
return TRUE;
}
int main(){
std::cout<<"Listing processes\n";
ListProcesses();
std::cin.get();
return 0;
}
Now adapt this code to your needs.
NOTE the 32 in the types names. That referes to 32-bit processes. Later with 64-bit CPU we'll use 64, for 64 bit processes, and 32 for 32 bit processes running on 64 bit machine, although emulated.
-
thx m8 thats probably what i was looking for!
-
http://msdn.microsoft.com/library/de..._processes.asp
That link shows code for listing all the processes (That code gives process name, like explorer.exe and also gives process ID of each one). My suggestion is make a simple class to hold process name, PID, and handle. Then make a list of that class, and instead of printing them to the screen, insert them into a list, then you have a list you can search through processes and such. I have just recently done this, if you want any help, IM or email me.