Determine When An App Is Complete

Determine When An App Is Complete

In VB3, you call GetModuleUsage() to determine when an app you startedwith the Shell command was complete. However, this call does not work correctlyin the 32-bit arena of Windows NT and Windows 95. To overcome this obstacle, use a routine in both 16- and 32- bit environmentsthat will tell you when a program has finished, even if it does not createa window. The IsInst() routine uses the TaskFirst and TaskNext functions definedin the TOOLHELP.DLL to see if the instance handle returned by the Shellfunction is still valid. When IsInst() returns False, the command has finished.You can call it in a loop:

 hInst = Shell("foobar.exe")Do While IsInst(hInst)	DoEventsLoopFunction 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)	LoopEnd Function
See also  How to Avoid Money Transfer Scams  

About Our Editorial Process

At DevX, we’re dedicated to tech entrepreneurship. Our team closely follows industry shifts, new products, AI breakthroughs, technology trends, and funding announcements. Articles undergo thorough editing to ensure accuracy and clarity, reflecting DevX’s style and supporting entrepreneurs in the tech sphere.

See our full editorial policy.

About Our Journalist