I need to kill an application roughly so I can get phantom subscriber of that application in my database (this can not be produced by closing the application). Manually, if we kill the application from Task Manager, the phantom subscriber will be exist. Now I need to do it automatically in VB 6 code. Help! Thanks.
There are two ways:
Send WM_CLOSE
to the target application if it has a window (hidden/visible). Task Manager's "End Task" uses this method. Most of the applications handle WM_CLOSE and terminate gracefully.
Use TerminateProcess
API to kill forcefully - Task Manager's "End Process" uses this method. This API forcefully kills the process.
An example can be found here: