Closing a group of applications in windows Ce

Hi all,

I have a bunch of applications running under Windows CE 5.0
I would like to develop an application that will automatically close (gracefully) these applications before continuing to do something.
I am considering getting the handles of each of these files, and then use TerminateProcess to close each one.
Is this graceful? Will it instruct the application to close before deciding to kill the task?
If not is there a better solution?

Thanks,

James
LVL 4
James AtkinSenior Principle Software EngineerAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

alexey_gusevCommented:
TerminateProcess() is never graceful, it simply kills the process.

I'd try to get their main window's handles and then send them WM_CLOSE message.
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
James AtkinSenior Principle Software EngineerAuthor Commented:
Sounds more sensible....
What is the best way to do this?
0
alexey_gusevCommented:
you could use EnuWindows() function to get iterated through all top-level windows, collect the handles and window titles (and window classes) - just like you'd see in Spy utility, then you select the desired window and call

SendMessage(hWnd,WM_CLOSE,0,0)

or

PostMessage(hWnd,WM_CLOSE,0,0)
0
Introducing Cloud Class® training courses

Tech changes fast. You can learn faster. That’s why we’re bringing professional training courses to Experts Exchange. With a subscription, you can access all the Cloud Class® courses to expand your education, prep for certifications, and get top-notch instructions.

James AtkinSenior Principle Software EngineerAuthor Commented:
Excellent! Thanks for all the help.
Best regards,
James
0
alexey_gusevCommented:
in the prev post: I meant of course EnumWindows()
0
James AtkinSenior Principle Software EngineerAuthor Commented:
:-) Thanks
0
James AtkinSenior Principle Software EngineerAuthor Commented:
Me again!

I have just discovered another simple way of doing this:

   Process proc = Process.GetProcessById(ProcessID);
   proc.CloseMainWindow();

This appears to be a nice simple .NET wrapper!

Best regards,

James
0
alexey_gusevCommented:
while it works, that is :)
0
James AtkinSenior Principle Software EngineerAuthor Commented:
I hope you're not implying that the .NET libraries are not wonderful... hee hee...
0
alexey_gusevCommented:
under Windows Mobile? they're HORRID :)
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Windows OS

From novice to tech pro — start learning today.

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.