General information
Category:
Windows API functions
Michael, closing an app softly is probably a bit tricky in this case because you have a process id and posting a WM_QUIT message requires either a window handle or a thread id. While there are API functions that obtain the process id from a window handle or thread id the reverse is not true, and finding windows or threads for a given process id involves some sort of enumeration (for example EnumWindows()). This is easy enough in C++ or Delphi but not in Fox.
Also, posting WM_QUIT can fail if the app has a modal dialog open that uses the Microsoft-provided modal loop, because then the WM_QUIT message will be simply discarded. That is why 'process killers' usually try sending WM_QUITs to close the app normally but if the app in question does not go away within a grace period of xxx seconds then they use the big hammer, i.e. TerminateProcess(). I don't know of any shortcuts but the behaviour of the Windows task manager seems to indicate that Microsoft doesn't know any, either. ;-)
Despite this I think it is worth it to try the 'polite' approach first, because it gives the app a chance to release resources and clean up after itself, things like network (server) sessions and temporary files etc. The overhead isn't much - just one or two dozen lines of C++/Delphi code, and if you went from exe path to process id then you probably have a bit of that already. ;-)
Previous
Next
Reply
View the map of this thread
View the map of this thread starting from this message only
View all messages of this thread
View all messages of this thread starting from this message only