[1]. Picture Processorusage.png Skip to [1] [2] [3] [4] [5] [2]. File Processorusage.zip ~ 16KBDownload($) Skip to [1] [2] [3] [4] [5] [3] The file does not exist or the code language does not exist. File ProcessorUsage.ARMV4I.zip ~ 225KBDownload(a) Skip to [1] [2] [3] [4] [5] [4] The file does not exist or the code language does not exist. Code [C/c++/objective-c] Code Skip to [1] [2] [3] [4] [5] ?
12345678910111213141516171819202122 |
/// Convert a FILETIME to ticks (ms)
DWORD GetThreadTick(
const FILETIME&
time )
{
__int64
tick = MAKEDWORDLONG(
time
.dwLowDateTime,
time
.dwHighDateTime );
return
static_cast
<
DWORD >( tick /= 10000 );
}
FILETIME creation = { 0 },
exit
= { 0 },
kernel = { 0 },
user = { 0 };
::GetThreadTimes( (
HANDLE )thread_id,
&creation,
&
exit
,
&kernel,
&user )
// time in ms spent in kernel space
DWORD
kernel_tics = GetThreadTick( kernel );
// time in ms spent in user space
DWORD
user_tics = GetThreadTick( user );
|
[5]. Code [C/c++/objective-c] Code Skip to [1] [2] [3] [4] [5] ?
1234567891011121314151617181920 |
HANDLE
snapshot = ::CreateToolhelp32Snapshot( TH32CS_SNAPTHREAD, 0 );
if
( INVALID_HANDLE_VALUE != snapshot )
{
THREADENTRY32 te = { 0 };
te.dwSize =
sizeof
( THREADENTRY32 );
if
( ::Thread32First( snapshot, &te ) )
{
do
{
// The te.th32ThreadID member will give us the thread ID of
// every thread running in the system.
// te.th32OwnerProcessID tells us which process owns that
// thread.
}
while
( ::Thread32Next( snapshot, &te ) );
}
::CloseToolhelp32Snapshot( snapshot );
}
|
Get a list of processes and CPU usage on a Windows mobile phone