I'm trying to get a percentage of CPU usage using Delphi, I've tried this solutions:
How to retrieve cpu usage per process
Get the Percentage of Total CPU Usage
https://forum.lazarus.freepascal.org/index.php?topic=38839.0
https://www.mitec.cz/msics.html
However, in all of them it always returns an incorrect value if we compare it with what Resource Monitor shows me on Windows, especially when it exceeds 25% of the total CPU. When I even tried to get it from the specific process, it also showed a wrong value. With tests performed on some machines, the value shown is always higher, in others machines the value is always lower than the value shown in the Task Manager. Using the same setup, normally I get 7% difference with the real value, but in some cases the Resource Monitor shows 50% and the delphi rotine shows 5%. I've made a test application using C#, creating a PerformanceCounter and it shows me exactly what Resource Monitor shows on Windows(on the same machines). Is there any solution to get CPU usage correctly using Delphi? Thanks in advance