Windows process binding cpu

HANDLE WINAPI GetCurrentProcess (void);
1. Return the pseudo handle of the current process (always return -1)
2. -1 indicates the pseudo handle of the current process
3, -2 indicates the pseudo handle of the current thread, you can try it with GetCurrentThread (always Return -2)
4. Do not use the value -1 directly. For future compatibility, please use GetCurrentProcess
5. The pseudo handle is not inherited. Think about what -1 means if it can be inherited (the pseudo handle of the parent process? The child process Pseudo handle?)
6. You can get the real handle of the current process through DuplicateHandle and OpenProcess.
7. The pseudo handle can be used in the current process. If you need to communicate across processes, you must come up with your own real handle.
8. The pseudo handle does not require CloseHandle. Even if calling CloseHandle does not work
9, if you need to obtain the real handle of the current process through DuplicateHandle and OpenProcess, you need CloseHandle when it is not in use to prevent the handle from leaking

Finally SetProcessAffinityMask

Guess you like

Origin www.cnblogs.com/caopf/p/12697965.html