Solved

Killing Child Process

Posted on 1997-08-13
5
256 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?
0
Comment
Question by:Fot
  • 3
  • 2
5 Comments
 
LVL 5

Accepted Solution

by:
y96andha earned 50 total points
Comment Utility
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
 

Author Comment

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

0
 
LVL 5

Expert Comment

by:y96andha
Comment Utility
Will you be using Win95, Win3.1 or WinNT?
0
 

Author Comment

by:Fot
Comment Utility
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
 
LVL 5

Expert Comment

by:y96andha
Comment Utility
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

Free Trending Threat Insights Every Day

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

Join & Write a Comment

Have you ever wanted to restrict the users input in a textbox to numbers, and while doing that make sure that they can't 'cheat' by pasting in non-numeric text? Of course you can do that with code you write yourself but it's tedious and error-prone …
If you have ever used Microsoft Word then you know that it has a good spell checker and it may have occurred to you that the ability to check spelling might be a nice piece of functionality to add to certain applications of yours. Well the code that…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…

728 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

9 Experts available now in Live!

Get 1:1 Help Now