| 
 | 
|  |   |  | |
|  |  |  | |
|  |  | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 
 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|  | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 
 | ||
| Visual Basic FAQ GetModuleUsage: Determine when a Shelled App has Ended (16-bit) | ||
| Posted: | Thursday December 26, 1996 | |
| Updated: | Monday December 26, 2011 | |
| Applies to: | VB3, VB4-16 on Windows 3.x | |
| Prerequisites | 
| None. | 
|  | 
| This is a 16-bit FAQ to launch an application and wait for its closing before continuing executing VB code. The Windows 3x GetModuleUsage API is not implemented under the Win32 operating system. | 
| BAS Module Code | 
| None. | 
|  | 
| Form Code | 
|   | 
| Add a command button to a form along with the following code: | 
|  | 
| Option Explicit '''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''' ' Copyright ©1996-2011 VBnet/Randy Birch, All Rights Reserved. ' Some pages may also contain other copyrights by the author. '''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''' ' Distribution: You can freely use this code in your own ' applications, but you may not reproduce ' or publish this code on any web site, ' online service, or distribute as source ' on any media without express permission. '''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''' Private Declare Function GetModuleUsage Lib "kernel" _
   (ByVal hModule As Integer) As Integer
Sub Command1_Click()
   RunShell "c:\windows\notepad.exe"
End Sub
Private Sub RunShell (cmdline As String)
    Dim hProcess As Integer
    hProcess = Shell(cmdline, 1)
    While GetModuleUsage(hProcess)
        DoEvents
    Wend
   MsgBox "The Shelled process " & cmdline & " has ended."
End Sub | 
| Comments | 
|  | 
| 
 | 
|  | |||||
| 
 | |||||
|  | |||||
| 
            	
            	Copyright ©1996-2011 VBnet and Randy Birch. All Rights Reserved. | 
|  |