Administrator
asked on
How could I know the CPU usage ?
I'd like to know my CPU usage (charge) in real time, like the little app "sysmon" which comes with windows 95.
The problem is that I haven't found what kind of win32api I have to use...
Anybody could help me ?
The problem is that I haven't found what kind of win32api I have to use...
Anybody could help me ?
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
This is exactly what I wanted !!! Thanx a lot ;-)
work. The following code is now correct:
//////////////////
// Begin of code.
// Open and read the StartSrv:KERNEL value
HKEY hWin95StartSrv;
HKEY hWin95Key;
HKEY hWin95StartStat;
DWORD ValType;
DWORD cpuPerCent;
DWORD cbData = sizeof(cpuPerCent);
BYTE ValBuffer[512];
RegOpenKeyEx(HKEY_DYN_DATA
"PerfStats\\StartSrv",
0,
KEY_READ,
&hWin95StartSrv
);
RegQueryValueEx(hWin95Star
"KERNEL\\CPUUsage",
NULL,
&ValType,
(LPBYTE)&ValBuffer,
&cbData);
// Open and read the StartStat:KERNEL\CPUUsage value
// This mysteriously enables the StatData:KERNEL\CPUUsage
// value.
RegOpenKeyEx(HKEY_DYN_DATA
"PerfStats\\StartStat",
0,
KEY_READ,
&hWin95StartStat
);
RegQueryValueEx(hWin95Star
"KERNEL\\CPUUsage",
NULL,
&ValType,
(LPBYTE)&ValBuffer,
&cbData);
// Open and read the StatData:KERNEL\CPUUsage key to
// reset the CPU meter
RegOpenKeyEx(HKEY_DYN_DATA
"PerfStats\\StatData",
0,
KEY_READ,
&hWin95Key
);
RegQueryValueEx(hWin95Key,
"KERNEL\\CPUUsage",
NULL,
&ValType,
(LPBYTE)&cpuPerCent,
&cbData);
// cpuPerCent now contains an integer value between 0 and
// 100
/////////////////
// End of code.