码迷,mamicode.com
首页 > 移动开发 > 详细

获取 Windows Mobile 手机上进程列表和CPU占用率

时间:2014-12-30 20:48:21      阅读:219      评论:0      收藏:0      [点我收藏+]

标签:

[1].[图片] ProcessorUsage.png 跳至 [1] [2] [3] [4] [5]

技术分享

[2].[文件] ProcessorUsage.zip ~ 16KB    下载(66) 跳至 [1] [2] [3] [4] [5]

文件不存在或者代码语言不存在

[3].[文件] ProcessorUsage.ARMV4I.zip ~ 225KB    下载(68) 跳至 [1] [2] [3] [4] [5]

文件不存在或者代码语言不存在

[4].[代码] [C/C++/Objective-C]代码 跳至 [1] [2] [3] [4] [5]

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
/// 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].[代码] [C/C++/Objective-C]代码 跳至 [1] [2] [3] [4] [5]

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
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 );
}

获取 Windows Mobile 手机上进程列表和CPU占用率

标签:

原文地址:http://blog.csdn.net/u014311051/article/details/42269057

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!