取内存CPU使用率模块

易语言 2020-10-03 17:20:28

取内存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