问题
What is the maximum process id I can get by calling DWORD GetProcessId(HANDLE)
or DWORD GetCurrentProcessId()
? It is not documented on the API's documentation page.
回答1:
According to the Pushing the Limits of Windows: Processes and Threads blog post by Mark Russinovich number of processes is limited only by available memory. So theoretically maximum process id is near DWORD_MAX (pids are divisible on 4).
回答2:
I couldn't find an official statement on it but since it's stored and returned as a DWORD you should assume it can use the entire 32-bit range. In practical systems I've never seen a PID large than ~200,000 though - since Windows will reuse PIDs they rarely get larger.
来源:https://stackoverflow.com/questions/17868218/what-is-the-maximum-process-id-on-windows