
TaskNext and TaskFirst functions
VBPJ posted a tip on http://www.*-*-*.com/ on how to determine if an app
is complete.
I wrote the following test code but I get a run-time error '48':
Function IsInst(hInst As Long) 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
'Declarations
Private Type TaskEntry
dwSize As Long
HTASK As Long
hTaskParent As Long
hInst As Long
hModule As Long
wSS As Long
wSP As Long
wStackTop As Long
wStackMinimum As Long
wStackBottom As Long
wcEvents As Long
hQueue As Long
' szModule(MAX_MODULE_NAME + 1) As String
wPSPOffset As Long
hNext As Long
End Type
Private Declare Function TaskNext Lib "toolhelp.dll" Alias "TASKNEXT" _
(taskstruct As TaskEntry) As Long
Private Declare Function TaskFirst Lib "toolhelp.dll" Alias "TASKFIRST" _
(taskstruct As TaskEntry) As Long
Private Sub Command1_Click()
Dim hInst As Long
hInst = Shell("notepad.exe")
Do While IsInst(hInst)
DoEvents
Loop
MsgBox "Hello"
End Sub
-------------------------------------------------------
Thanks for any help,
Dan Stoelting