Application Launching Another

‘Description: Shell Function. Runs an executable program. Wait for program to
‘             terminate. Time out after 30 seconds.

‘Declare Function GetModuleUsage Lib “Kernel” (ByVal hModule As Integer) As Integer
‘Const SW_HIDE = 0      ‘Normal Window
‘Const SW_NORMAL = 1    ‘Maximized Window
‘Const SW_MAXIMIZE = 3  ‘Minimized Window
‘Const SW_MINIMIZE = 6  ‘Hidden Window

‘Sub Command1_Click ()
On Error Resume Next
command1.Enabled = False
startt! = Timer
timeout% = False
Do While GetModuleUsage(iInst%) > 0
If Abs(Timer – startt!) > 30 Then
timeout% = True
Exit Do
End If

If timeout% Then MsgBox “Timed out, 30 seconds passed!”, 0, “Warning”
command1.Enabled = True
‘End Sub

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s