Click here to Skip to main content
15,867,835 members
Articles / Programming Languages / eVC

A Simple Windows Mobile 5.0 Task Enumerator

Rate me:
Please Sign up or sign in to vote.
4.38/5 (6 votes)
11 Dec 2005CPOL2 min read 63.5K   409   25   11
A simple task enumerator for Windows Mobile SmartPhones.

Introduction

This is a part of a big initiative which includes some task management activities for Windows Mobile 5.0. I hope this would give you an idea of Windows Mobile 5.0 task management APIs and their implementations. I believe you have a good idea of Win32 architecture to fully understand this stuff.

About Windows Task Manager

Windows Task Manager is a user interface extended by the Windows OS to help users manage tasks. The user interface includes all the details of a basic task (process) context and presents it in a friendly interface. I have tried creating some interfaces like this in the PC world using VC++/MFC.

The Associated APIs

Rather than explaining the full source code in detail, I would give you an idea of the APIs specific for task management. Since the basic process libraries which include the APIs like TerminateProcess, EnumerateProcess remain unavailable in the Windows Mobile environment, I tried using some other APIs.

I have created a thread to run in background to enumerate all the tasks. See the thread DWORD WINAPI ProcessViewThread(PVOID lParam).

Let's start now:

  1. The thread first takes a snapshot of the system processes by using the CreateToolhelp32Snapshot() API, which returns a handle to the snapshot for further usage.
  2. Then, the thread calls Process32First() to get the details of the first process into a PROCESSENTRY32 predefined structure.
  3. It sends a Windows message to the list control added in the GUI to intimate about the new entry into it, by handling the LB_ADDSTRING Windows list control message.
  4. Then, it iteratively calls Process32Next() till it returns a FALSE. That means all the information of all the processes has been captured.
  5. But the program should safely close the handle to the snapshot by calling CloseToolhelp32Snapshot() to avoid resource/handle leaks.

That's all about it.

Further Modifications Required

  1. The listbox which enumerates all the processes lists them very slow. It would be great if you could collect all the process names in a buffer and update it in the list box in a regular fashion.
  2. TODO: Currently working to improve the GUI, include more process details, etc. the project.

Latest Additions

  1. Added facility to stop a process.
  2. Added soft-key enabled operations.

Comments solicited.

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


Written By
Technical Lead
India India
I am a personality from Trivandrum , a green peaceful place in Kerala, South India.
I have been an enthusiast of Windows programming when I started creating simple windows when I learnt VC++ in LCC in Trivandrum. From then on its all about Windows in my flesh and blood.
My career graph moves like this:
1. I started working as a C/C++ programmer in a company in Trivandrum where I learnt the ABCs of Software Industry. I worked with them for about 1 year. I could not contine since I was in contract for 1 year.
2. Then I joined another organization in Trivandrum who gave me challenges to love. They made me mad about VC++ and Windows.
I was mad about Embedded Systems which made me, Myself = Embedded Systems + VC++.
3. Software Engineer in a telecom company in Hyderabad, Andhra Pradesh, S.India.
4. Currently working with a telecom company in Bangalore.
I totally, so, have experience of about 4.5 years.

Comments and Discussions

 
QuestionProblem to create dynamic buttons using MFC Pin
susilrani28-Apr-08 23:46
susilrani28-Apr-08 23:46 
Questionproblem in porting wince to smdk 2410 board. Pin
amiya das30-Mar-08 21:49
amiya das30-Mar-08 21:49 
GeneralRe: sms all Pin
Sreekanth Muralidharan8-Nov-06 6:37
Sreekanth Muralidharan8-Nov-06 6:37 
GeneralNice but a Suggestion... Pin
ThatsAlok12-Dec-05 17:09
ThatsAlok12-Dec-05 17:09 
GeneralRe: Nice but a Suggestion... Pin
Sreekanth Muralidharan12-Dec-05 17:13
Sreekanth Muralidharan12-Dec-05 17:13 
GeneralRe: Nice but a Suggestion... Pin
ThatsAlok12-Dec-05 17:54
ThatsAlok12-Dec-05 17:54 
GeneralRe: Nice but a Suggestion... Pin
Sreekanth Muralidharan12-Dec-05 23:58
Sreekanth Muralidharan12-Dec-05 23:58 
GeneralRe: Nice but a Suggestion... Pin
ThatsAlok13-Dec-05 0:09
ThatsAlok13-Dec-05 0:09 
JokeRe: Nice but a Suggestion... Pin
ThatsAlok12-Dec-05 17:57
ThatsAlok12-Dec-05 17:57 
GeneralRe: Nice but a Suggestion... Pin
Member 239604223-Jan-09 8:45
Member 239604223-Jan-09 8:45 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.