We help IT Professionals succeed at work.

Killing Child Process

Fot
Fot asked
on
Medium Priority
287 Views
Last Modified: 2008-02-20
After spawning a child process with the Shell() command, I need to be able to kill the same process at a later stage. Is there a way of ding this in VB4 Pro?
Comment
Watch Question

Commented:
Use OpenProcess to get a process handle from the return value from the Shell() command. Then use TerminateProcess with the process handle when you need to kill the process. This is assuming that you're using the 32-bit version of VB4.

Not the solution you were looking for? Getting a personalized solution is easy.

Ask the Experts
Fot

Author

Commented:
Oops! Sorry, I forgot to mentin that I am using VB4 Pro (16-bit), not the 32-bit version. Any other ideas?

Commented:
Will you be using Win95, Win3.1 or WinNT?
Fot

Author

Commented:
The application in question will be required to run on both Win3.1 and Win95 workstations in the near future, and possibly WinNT further down the line. I don't particularly wish to start messing around with Win32, and I can't possibly shut out our current Win3.1 users, as they make up approx. 60% of our user base.

Commented:
In toolhelp.dll, there is a function called TerminateApp which will kill a process given its task handle.

Declare Sub TerminateApp Lib "toolhelp" (ByVal hTask As Integer, ByVal flags as Integer)

flags = 0 will popup a message box, flags = 1 will close the task quietly.

I know that the return value from the shell function is a PID in 32-bit, but  I am not sure what the return value from the shell funtion is in 16-bit?
Access more of Experts Exchange with a free account
Thanks for using Experts Exchange.

Create a free account to continue.

Limited access with a free account allows you to:

  • View three pieces of content (articles, solutions, posts, and videos)
  • Ask the experts questions (counted toward content limit)
  • Customize your dashboard and profile

*This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.

OR

Please enter a first name

Please enter a last name

8+ characters (letters, numbers, and a symbol)

By clicking, you agree to the Terms of Use and Privacy Policy.