Click here to Skip to main content
65,938 articles
CodeProject is changing. Read more.
Articles
(untagged)

A Simple Windows Mobile 5.0 Task Enumerator

0.00/5 (No votes)
11 Dec 2005 1  
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 has no explicit license attached to it but may contain usage terms in the article text or the download files themselves. If in doubt please contact the author via the discussion board below.

A list of licenses authors might use can be found here