Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
TerminateProcess()
Message
De
15/12/2003 19:06:18
 
 
À
15/12/2003 16:03:28
Information générale
Forum:
Visual FoxPro
Catégorie:
Fonctions Windows API
Divers
Thread ID:
00859248
Message ID:
00859363
Vues:
24
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. ;-)
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform