VBcoders Guest



Don't have an account yet? Register
 


Forgot Password?



Determine when an app launches with SHELL is done

by VB Pro (6 Submissions)
Category: Windows System Services
Compatability: Visual Basic 3.0
Difficulty: Unknown Difficulty
Date Added: Wed 3rd February 2021
Rating: (4 Votes)

In VB3, you call GetModuleUsage() to determine when an app you started with the Shell command was complete. However, this call does not work correctly in the 32-bit arena of Windows NT and Windows 95.
To overcome this obstacle, use a routine in both 16- and 32- bit environments that will tell you when a program has finished, even if it does not create a window.
The IsInst() routine uses the TaskFirst and TaskNext functions defined in the TOOLHELP.DLL to see if the instance handle returned by the Shell function is still valid. When IsInst() returns False, the command has finished.

Rate Determine when an app launches with SHELL is done

hInst = Shell("foobar.exe")
Do While IsInst(hInst)
DoEvents
Loop
Function IsInst(hInst As Integer) As Boolean
Dim taskstruct As TaskEntry
Dim retc As Boolean
IsInst = False
taskstruct.dwSize = Len(taskstruct)
retc = TaskFirst(taskstruct)
Do While retc
If taskstruct.hInst = hInst Then
' note: the task handle is: taskstruct.hTask
IsInst = True
Exit Function
End If
retc = TaskNext(taskstruct)
Loop
End Function

Download this snippet    Add to My Saved Code

Determine when an app launches with SHELL is done Comments

No comments have been posted about Determine when an app launches with SHELL is done. Why not be the first to post a comment about Determine when an app launches with SHELL is done.

Post your comment

Subject:
Message:
0/1000 characters