Set CPU priority on Windows in C++

In Windows, CPU priority, as the name suggests, will make the process have higher CPU priority than other processes. There are 7 types of CPU priorities. From lowest to highest, they are: "Idle", "Low", "Below Normal", "Normal", "Above Normal", "High", and "Realtime". The function requires at least Windows NT 4.0. This works in both Visual C++ and MinGW.

Example code

The above example code will get the current process, set it to the "Realtime" priority, and keep it running so we can verify. There are also other priority classes we can use.