易语言取CPU占用率

易语言 2020-08-06 19:17:24

易语言取CPU占用率

lngResult = NtQuerySystemInformation_sti (#SYSTEM_TIME_INFORMATION, sti, 32, 0)
.如果真 (lngResult ≠ 0)
返回 (-1)
.如果真结束
lngResult = NtQuerySystemInformation_spi (#SYSTEM_PERFORMANCE_INFORMATION, spi, 312, 0)
.如果真 (lngResult ≠ 0)
返回 (-1)
.如果真结束
curIdle = spi.liIdleTime - lidOldIdle
curSystem = sti.liKeSystemTime - liOldSystem
.如果真 (curSystem ≠ 0)
lngResult = curIdle ÷ curSystem
.如果真结束
lngResult = 100 - lngResult × 100 ÷ 到数值 (读环境变量 (“NUMBER_OF_PROCESSORS”))
lidOldIdle = spi.liIdleTime
liOldSystem = sti.liKeSystemTime