• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 272
  • Last Modified:

Killing Child Process

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?
0
Fot
Asked:
Fot
  • 3
  • 2
1 Solution
 
y96andhaCommented:
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.
0
 
FotAuthor Commented:
Oops! Sorry, I forgot to mentin that I am using VB4 Pro (16-bit), not the 32-bit version. Any other ideas?

0
 
y96andhaCommented:
Will you be using Win95, Win3.1 or WinNT?
0
 
FotAuthor 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.
0
 
y96andhaCommented:
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?
0

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

  • 3
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now