• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 1979
  • Last Modified:

How can I programmatically terminate a process in windows mobile 6

I have a windows mobile 6 PDA/phone.
I have noticed that most applications for the platform don't properly terminate on exiting, they simply minimize and take up memory. In order to close them I have to go to Start-Settings-System-Memory-Running Programs and then click Stop All, or else the device will start to lag after using a few applications.
It would be nice to write small app that would loop through all open application processes and terminate them, to accomplish the task with one tap from the Today screen, instead of going into system settings every time I use an application, such as receiving a text message.
Does such an application exist? If not, which API could I use to write my own app for it?
  • 2
  • 2
  • 2
  • +3
1 Solution
Not that this answers your question regarding WM 6.0 but 6.1 now includes a task manager and it can be set on your Start menu and one tap gets to it, then you can select End All Tasks. Is 6.1 an option for your devices? The Task Manager is certainly my favorite feature of 6.1.

If not, there are some add-ons out there if you google: windows mobile task manager
in CF 2.0 you can just use

Get expert help—faster!

Need expert help—fast? Use the Help Bell for personalized assistance getting answers to your important questions.

the key API here is ToolHelp API - CreateToolhelp32Snapshot(), Process32First/Next() etc - to enumerate all running processes if you're doing it in C++ (or use P/Invoke wrappers in cf.net available either in cf itself or OpenNETCF):

      HANDLE hSnapshot = CreateToolhelp32Snapshot(TH32CS_SNAPPROCESS|TH32CS_SNAPNOHEAPS, 0);

Pay attention on TH32CS_SNAPNOHEAPS (0x40000000) - it prevents ~1MB heap allocation during snapshot creation :).

Once you have process ID, you can either brutally terminate it with TerminateProcess() or try to find a window (eg with EnumWindows() ) that belongs to that process and send it WM_CLOSE message to allow it to exit gracefully. Again, you can use P/Invoke wrappers if you develop in cf.net

Re. existing applications - well, google for Task Manager for mobile, I guess you can find something.
In followup to my comment, check with your mobile carrier to see if they have a 6.1 upgrade, or if it is an unlocked device, check directly with the manufacturer (HTC, Samsung). I've upgraded a few models this year with both sources for the 6.1 ROMs.
In the right-top corner should be a button that opens a drop down list with all running applications. Each item in this list has a close button on the right side.  This is the correct way to close the running applications. This application has name - Task Manager.
It's done so accordignly to the MS requiremenets/recommendations. That was (or is) Windows Mobile Logo program. In order to get this logo, all developers tried to to follow the MS guidelines. Looks like now this program is replaced by Windows Mobile Marketplace.
Here is a document about it: http://developer.windowsmobile.com/resources/en-US/Application%20Submission%20Guidelines.pdf
Here is the UI guidelines for 6:
Here is for 5: http://www.windowsfordevices.com/articles/AT4228820897.html
It is really so, each application has a "close" button. Almost always it is in the right-top corner. But this button just moves the current application to the background.
In order to really close the application it is enough just to send WM_CLOSE message to the main application window.
Of course, you can find a lot of task managers in the internet - not only you don't like this annoying feature.
For example, here is HTC Task Manager:
This is an app that cleans the memory of the PDA: close non-responding tasks, clean registry, automatic clean, etc. It is a kind of a softer solution that just terminate all running processes.
another cleaner: http://www.newfreedownloads.com/Windows-Utilities/System-Utilities/MindSoft-Mobile-Utilities.html
colonel720Author Commented:
The HTC task manager is really good, it even seems to detect when a window is closed with the "x" button and terminates the process. Guess I don't need to reinvent the wheel...
Thanks, and thanks to all who responded.

Thats All

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

  • 2
  • 2
  • 2
  • +3
Tackle projects and never again get stuck behind a technical roadblock.
Join Now