Solved

How can I programmatically terminate a process in windows mobile 6

Posted on 2009-07-16
9
1,952 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
Revamp Your Training Process

Drastically shorten your training time with WalkMe's advanced online training solution that Guides your trainees to action.

 
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

Create the perfect environment for any meeting

You might have a modern environment with all sorts of high-tech equipment, but what makes it worthwhile is how you seamlessly bring together the presentation with audio, video and lighting. The ATEN Control System provides integrated control and system automation.

Question has a verified solution.

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

A project that enables an administrator to perform actions within a user session context not just at the time of login but any time later on day(s) or week(s) later.
Windows 10 Creator Update has just been released and I have it working very well on my laptop. Read below for issues, fixes and ideas.
In this video, we discuss why the need for additional vertical screen space has become more important in recent years, namely, due to the transition in the marketplace of 4x3 computer screens to 16x9 and 16x10 screens (so-called widescreen format). …
This Micro Tutorial will give you a basic overview of Windows DVD Burner through its features and interface. This will be demonstrated using Windows 7 operating system.

690 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