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
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:
- 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.
- Then, the thread calls
Process32First() to get the details of the first process into a
PROCESSENTRY32 predefined structure.
- 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.
- Then, it iteratively calls
Process32Next() till it returns a
FALSE. That means all the information of all the processes has been captured.
- 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
- 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.
- TODO: Currently working to improve the GUI, include more process details, etc. the project.
- Added facility to stop a process.
- Added soft-key enabled operations.