Handle of process to process id
When spawnX() starts a process in asynchronous mode it returns the handle of the new process. Somne functions dealing with processes e.g. GetWindowsThreadProcessID() return the processes ID. What's the relationship between handle and id? Is there a function for transformation?
Thanks in advance for your reply!
Re: Handle of process to process id
An ID identifies the process and/or thread in your current windows session. To gain access to a thread/process (e.g. to check its status, kill it and so on) you need to "open" the Process. The open process takes the ID (to lookup the right process you are looking for) and returns the handle. The handle may store additional information along: Do you have termination rights? Do you have read/write rights? And so forth. The handle then may be passed to other functions like TerminateThread and so on.
Re: Handle of process to process id
There is no conversion from handle to ID, but one can call OpenProcess(ID) to get the handle.
If you use CreateProcess to spawn/create the process, then you get the handle and ID both in PROCESS_INFORMATION structure.