Answered by:
How to get window handles in Windows Mobile

Question
-
Hi,I have an application that need to start other applications. I want to be able to check if the application is already running and if so to just bring it to front rather than attempting to start a new process. Is there any way to parse through the applications already running on my device and get the windows handle, so i can pInvoke a SetForeGroundWindow using this code:[DllImport("coredll.dll")]extern public static bool SetForegroundWindow (IntPtr hWnd);To run this, when i loop through the processes I need a reliable way to then get the process handle.Also, as a side note, when looping through the processes, is there any way to tell if the open window of a process has close or minimize box?Thanks very much in advance!
Rob McCabeSunday, November 29, 2009 1:25 PM
Answers
-
Hi,
The following may provide a starting point :-
http://msdn.microsoft.com/en-us/library/aa446560.aspx
Hope this helps.
Paul Diston
http://www.smartmobiledevice.co.uk/- Marked as answer by warrentang Thursday, December 3, 2009 3:11 AM
Sunday, November 29, 2009 3:21 PM -
1. First you need to enumerate all the top-level windows. Check out the following link on how to retrieve Main Windows Handles and their Titles.
http://blog.tcx.be/2006/05/getting-list-of-all-open-windows.html
2. Use the Process List retrieved by the code in the article that Paul suggested above and match it with the values you find in step 1 and perform appropriate action.
- Onkar
http://www.42gears.com
[SureLock Studio: Quick and Easy way to lockdown Enterprise Windows Mobile devices]- Marked as answer by warrentang Thursday, December 3, 2009 3:11 AM
Monday, November 30, 2009 10:00 AM
All replies
-
Hi,
The following may provide a starting point :-
http://msdn.microsoft.com/en-us/library/aa446560.aspx
Hope this helps.
Paul Diston
http://www.smartmobiledevice.co.uk/- Marked as answer by warrentang Thursday, December 3, 2009 3:11 AM
Sunday, November 29, 2009 3:21 PM -
Hi Paul,That was a great start thanks! Do you know how to get the main window text of a process (if it has one) and how would I use the code provided to bring a process main window to the font (again, if it has one)?Thanks very much!
Rob McCabeMonday, November 30, 2009 9:10 AM -
1. First you need to enumerate all the top-level windows. Check out the following link on how to retrieve Main Windows Handles and their Titles.
http://blog.tcx.be/2006/05/getting-list-of-all-open-windows.html
2. Use the Process List retrieved by the code in the article that Paul suggested above and match it with the values you find in step 1 and perform appropriate action.
- Onkar
http://www.42gears.com
[SureLock Studio: Quick and Easy way to lockdown Enterprise Windows Mobile devices]- Marked as answer by warrentang Thursday, December 3, 2009 3:11 AM
Monday, November 30, 2009 10:00 AM -
Sorry I thought I mentioned this was on Windows Mobile, that link works for desktop only. I could not find equivalent windows mobile methods on the pinvoke web site?
Rob McCabeMonday, November 30, 2009 10:31 AM -
EnumWindows is the main function in that code and it does work on Windows Mobile, so you should be able to use it. You don't need to use whole code in that article. That was for your reference only.
- Onkar
http://www.42gears.com
[SureLock Studio: Quick and Easy way to lockdown Enterprise Windows Mobile devices]Monday, November 30, 2009 11:00 AM