Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 520
  • Last Modified:

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
0
James Atkin
Asked:
James Atkin
  • 5
  • 5
1 Solution
 
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
 
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
What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

 
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

Featured Post

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

  • 5
  • 5
Tackle projects and never again get stuck behind a technical roadblock.
Join Now