扫一扫
分享文章到微信
扫一扫
关注官方公众号
至顶头条
typedef LONG (WINAPI *PROCNTQSI)(UINT,PVOID,ULONG,PULONG); PROCNTQSI NtQuerySystemInformation; NtQuerySystemInformation = (PROCNTQSI)GetProcAddress( GetModuleHandle("ntdll"), "NtQuerySystemInformation" ); if (!NtQuerySystemInformation) { return; } // get number of processors in the system status = NtQuerySystemInformation(SystemBasicInformation, &SysBaseInfo,sizeof(SysBaseInfo),NULL); if (status != NO_ERROR) { return; } status = NtQuerySystemInformation(SystemTimeInformation, &SysTimeInfo,sizeof(SysTimeInfo),0); if (status!=NO_ERROR) { return; } // get new CPU''s idle time status = NtQuerySystemInformation(SystemPerformanceInformation, &SysPerfInfo,sizeof(SysPerfInfo),NULL); if (status != NO_ERROR) { return; } // if it''s a first call - skip it if (m_liOldIdleTime.QuadPart != 0) { // CurrentValue = NewValue - OldValue dbIdleTime = Li2Double(SysPerfInfo.liIdleTime) - Li2Double(m_liOldIdleTime); dbSystemTime = Li2Double(SysTimeInfo.liKeSystemTime) - Li2Double(m_liOldSystemTime); // CurrentCpuIdle = IdleTime / SystemTime dbIdleTime = dbIdleTime / dbSystemTime; // CurrentCpuUsage% = 100 - (CurrentCpuIdle * 100) / NumberOfProcessors dbIdleTime = 100.0 - dbIdleTime * 100.0 / (double)SysBaseInfo.bKeNumberProcessors + 0.5; m_fNewUsges = (UINT)dbIdleTime; } |
MEMORYSTATUS MemStat; MemStat.dwLength = sizeof(MEMORYSTATUS); GlobalMemoryStatus(&MemStat); m_ulNewUsges = MemStat.dwMemoryLoad; |
such as:CMemUsgesCtl m_ MyMemCtrl; CCpuUsgesCtl m_ MyCpuCtrl; ………… if(!m_MyCpuCtrl.Create(WS_CHILD | WS_VISIBLE, rect, this, IDC_CPUCTL)) { TRACE0("Create m_MyCtrl Failed!"); return 0; } rect.left = rect.right + 20; rect.right += lpCreateStruct->cx / 2; if(!m_MyMemCtrl.Create(WS_CHILD | WS_VISIBLE,rect, this, IDC_MEMCTL)) { TRACE0("Create m_MyCtrl Failed!"); return 0; } |
如果您非常迫切的想了解IT领域最新产品与技术信息,那么订阅至顶网技术邮件将是您的最佳途径之一。
现场直击|2021世界人工智能大会
直击5G创新地带,就在2021MWC上海
5G已至 转型当时——服务提供商如何把握转型的绝佳时机
寻找自己的Flag
华为开发者大会2020(Cloud)- 科技行者