Solved

How can I programmatically terminate a process in windows mobile 6

Posted on 2009-07-16
9
1,949 Views
Last Modified: 2013-12-21
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?
0
Comment
Question by:colonel720
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
  • 2
  • 2
  • +3
9 Comments
 
LVL 40

Expert Comment

by:mrjoltcola
ID: 24871024
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
0
 
LVL 48

Expert Comment

by:Mikal613
ID: 24871042
in CF 2.0 you can just use

Process.Kill
0
 
LVL 48

Expert Comment

by:Mikal613
ID: 24871043
0
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 24

Expert Comment

by:alexey_gusev
ID: 24871157
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.
0
 
LVL 40

Expert Comment

by:mrjoltcola
ID: 24871257
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.
0
 
LVL 33

Accepted Solution

by:
pgnatyuk earned 500 total points
ID: 24872175
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:
http://msdn.microsoft.com/en-us/library/bb158602.aspx,
http://msdn.microsoft.com/en-us/library/ms854763.aspx
http://msdn.microsoft.com/en-us/library/ms854546.aspx
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:
http://www.freewarepocketpc.net/ppc-download-htc-task-manager-v2-0.html
 
 
0
 
LVL 33

Expert Comment

by:pgnatyuk
ID: 24873309
More:
http://www.dewantoro.net/search/free+memory+cleaner+windows+mobile+6
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
 
0
 
LVL 1

Author Closing Comment

by:colonel720
ID: 31604315
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.
0
 

Expert Comment

by:rameshbs85
ID: 25420461
 Process.GetCurrentProcess().Kill();

Thats All

Thanks
0

Featured Post

[Webinar] Code, Load, and Grow

Managing multiple websites, servers, applications, and security on a daily basis? Join us for a webinar on May 25th to learn how to simplify administration and management of virtual hosts for IT admins, create a secure environment, and deploy code more effectively and frequently.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

In this article, I will show you HOW TO: Install VMware Tools for Windows on a VMware Windows virtual machine on a VMware vSphere Hypervisor 6.5 (ESXi 6.5) Host Server, using the VMware Host Client. The virtual machine has Windows Server 2016 instal…
This article is a collection of issues that people face from time to time and possible solutions to those issues. I hope you enjoy reading it.
Windows 10 is mostly good. However the one thing that annoys me is how many clicks you have to do to dial a VPN connection. You have to go to settings from the start menu, (2 clicks), Network and Internet (1 click), Click VPN (another click) then fi…
This is used to tweak the memory usage for your computer, it is used for servers more so than workstations but just be careful editing registry settings as it may cause irreversible results. I hold no responsibility for anything you do to the regist…
Suggested Courses

732 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question