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.
相关问题
- Convert VB's Val to Java?
- Invalid Picture In Visual basic 6
- Compile is really slow for a solution with many pr
- vb6 Open File For Append issue Path Not Found
- DSN-less ODBC connect string for legacy Sybase Ada
相关文章
- Reading (with Filesystem.FileGet) VB6 record file
- Trim all types of whitespace, including tabs
- How to destroy an object
- How to prepend a header in a text file
- VB6 — using POST & GET from URL and displaying in
- Using a VB6.dll in .Net
- Dynamic two or more levels sub-menu generation in
- Convert VB6 app to WPF?
Karl Peterson's excellent archive of VB6 code has high quality sample code and full explanations using both WM_CLOSE and TerminateProcess. Accept no substitutes!
One pitfall you might see in a lot of code out there is that sending WM_CLOSE to a single window handle you have isn't sufficient - most applications comprise numerous windows. The answer as implemented in Karl's code: Find all the top-level windows belonging to this application and send the message to each.
Use vb6.0 TaskKill
There are two ways: 1. 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. 2. 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: http://www.vb-helper.com/howto_terminate_process.html
Call ShellExecute with the TaskKill command
This forces (
/f
) the terminatation of the process with the image name (/im
) of processname.exe, and any child processes which were started by it (/t
). You may not need all these switches. See thetaskkill
command help for more information (type the following at the command line):