Search code examples
winapiprocessshutdown

Win32 API For Shutting Down Another Process Elegantly?


I'm looking for a way to shutdown a windows app from another. Is there a way to do this?

Ideally I'd like something that basically mimics an ALT-F4, or pressing the 'X' in the top right corner or some such.

Alternatively, is there an application out there that does this already? tskill is a bit too harsh for what I have in mind.


Solution

  • According to your description this sounds like a windowed app. In that case you can send it a WM_CLOSE message to mimic the behavior when pressing the "X" button.

    Another alternative is to use TerminateProcess, but this is probably what tskill does as well.