Posted on 2005-02-09 01:44:38 by Sen
The same way as you would in any other language... Search the Web
Posted on 2005-02-09 07:15:15 by JimmyClif
but i am very bad in C++
can you tell me more details?
thank you very much.
Posted on 2005-02-10 04:31:56 by Sen
Straight from Codeproject:

Call this :

FILETIME idleTime;
FILETIME kernelTime;
FILETIME userTime;
BOOL res = GetSystemTimes( &idleTime, &kernelTime, &userTime );

and voil? you have almost what you need.

Now you have to poll this function and make a little calculus.

usr = userTime - last_userTime;
ker = kernelTime - last_kernelTime;
idl = idleTime - last_idleTime;

system time is :

sys = kerl + usr

idleTime is the rest because "System Idle" process is taking 100 % of cpu

so cpu is :

cpu = int( (sys - idl) *100 / sys );

If you can't translate this to masm, you might want to consider having another tut or two :)
Posted on 2005-02-10 21:11:57 by JimmyClif
sys = kerl + usr
Why kerl?i think this is must be a misstake

And here:
cpu = int( (sys - idl) *100 / sys )
I no good at C++.So i don't know the function of "int".How does it express in masm

idleTime FILETIME ?
kernelTime FILETIME ?
userTime FILETIME ?

invoke GetSystemTimes,offset idleTime,offset kernelTime,offset userTime
mov res,eax

dwLowDateTime DWORD ?
dwHighDateTime DWORD ?

How can i do:
usr = userTime - last_userTime;
ker = kernelTime - last_kernelTime;
idl = idleTime - last_idleTime;

Which data should i choose?dwHighDateTime - dwLowDateTime?
Posted on 2005-02-10 22:23:20 by Sen
Here's the link... It's only a couple lines... Translate it one line after after another...

Also use Google for some help.. "What is an int" is a good question for a search engine. ;)
Posted on 2005-02-11 09:35:06 by JimmyClif
Hi JimmyClif,Thank you very much!
But now here(China) is AM5:00,i am so tried.I will try later.Thx
Posted on 2005-02-11 15:14:51 by Sen