Subject: How to kill a DOS box in VB 
From: cnmlois@gatekeeper.ddp.state.me.us (Marc Loiselle) 
 
Several people expressed an interest in the answer to how to kill a DOS  
box in Visual Basic.  The following works like a charm: 
 
A method to close a DOS window opened with the Shell command in  
Visual Basic uses the TerminateApp function located in  
toolhelp.dll. Toolhelp.dll is included in Windows 3.1. 
 
    Syntax: 
 
    (Declarations) 
 
    ' TerminateApp 
    Declare Function TerminateApp% Lib "Toolhelp.dll" (ByVal hTask%,  
        ByVal wFlags%) 
    ' Get Windows task handle if window handle is known 
    Declare Function GetWindowTask% Lib "User" (Byval hWnd%) 
    . 
 
    (Code to start a DOS window and get the window handle) 
    . 
    . 
    hTask% = GetWindowTask(hWnd%)   ' Get Windows task handle 
    ti% = TerminateApp(hTask%, 1) 
 
 
wFlags% = 1 closes the box; wFlags% = 2 closes the box but produces  
a Windows application error message that must be closed by a mouse  
click. 
 
Thanks to:  Dan Appleman, Niels van Dijke, Steve Bridges, and an  
unknown respondant whose reply was removed from our system before I  
could read it.....  
