Login | Register   
LinkedIn
Google+
Twitter
RSS Feed
Download our iPhone app
TODAY'S HEADLINES  |   ARTICLE ARCHIVE  |   FORUMS  |   TIP BANK
Browse DevX
Sign up for e-mail newsletters from DevX


Tip of the Day
Language: Visual Basic
Expertise: Beginner
Aug 6, 1997

Determine When An App Is Complete

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. You can call it in a loop:
 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
A. Nicklas
 
Comment and Contribute

 

 

 

 

 


(Maximum characters: 1200). You have 1200 characters left.

 

 

Sitemap
Thanks for your registration, follow us on our social networks to keep up-to-date