// get number of processors in the system
status = NtQuerySystemInformation(SYS_BASIC_INFO, &SysBaseInfo, sizeof(SysBaseInfo), NULL);
if (status != NO_ERROR)
return 0;
while(!quiet)
{
// get new system time
status = NtQuerySystemInformation(SYS_TIME_INFO, &SysTimeInfo, sizeof(SysTimeInfo), 0);
if (status!=NO_ERROR)
return 0;
// get new CPU's idle time
status = NtQuerySystemInformation(SYS_PERFORMANCE_INFO, &SysPerfInfo, sizeof(SysPerfInfo), NULL);
if (status != NO_ERROR)
return 0;
// if it's a first call - skip it
if (liOldIdleTime.QuadPart != 0)
{
// CurrentValue = NewValue - OldValue
dbIdleTime = Li2Double(SysPerfInfo.liIdleTime) - Li2Double(liOldIdleTime);
dbSystemTime = Li2Double(SysTimeInfo.liKeSystemTime) - Li2Double(liOldSystemTime);