Checking Task List for Active Application 
Author Message
 Checking Task List for Active Application

Hi

I am using VB4 to run another Windows program (using Shell) with different
parameters which can take from 10 seconds to a minute or so to complete. How
can I check for the completion of this program (I assume I would need to
check the active task list until its id disappears but I don't know how to
do this)?

Any suggestions would be gratefully appreciated.

Thanks in advance

Phil Brewer



Fri, 05 Jan 2001 03:00:00 GMT  
 Checking Task List for Active Application
Hi

Pulled this code from my class so I can't guarantee that it's
complete, but  it'll give you an idea. There are samples out on
the net, got one from vbnet or similar site once.

best wishes

Murray

Private Declare Function OpenProcess Lib "kernel32" _
       (ByVal dwDesiredAccess As Long, _
        ByVal bInheritHandle As Long, _
        ByVal dwAppProcessId As Long) As Long

Private Declare Function GetExitCodeProcess Lib "kernel32" _
       (ByVal ApphProcess As Long, lpExitCode As Long) As Long

 Public AppProcessId As Long
 Public ApphProcess As Long

Function AppShell(Optional inArgs As Variant, Optional
inWindowAttribute As Variant) As Long
    Dim args As String
    Dim attr As String
    Dim ShellPath As String
    Dim ShellWin As String
    AppShell = 0
    If Not IsMissing(inArgs) Then
        ShellPath = HoldFile & " " & inArgs
    Else
        ShellPath = HoldFile
    End If
    If IsMissing(inWindowAttribute) Then
        ShellWin = vbMaximizedFocus
    Else
        ShellWin = inWindowAttribute
    End If
    AppShell = Shell(ShellPath, ShellWin)
    AppProcessId = AppShell
    ApphProcess = OpenProcess(PROCESS_QUERY_INFORMATION, False,
AppProcessId)
    ProcInfo.ProcessId = AppShell
    FindWindow
End Function

Function AppShellandWait(Optional inArgs As Variant, Optional
inWindowAttribute As Variant) As Boolean
    Dim id As Long
    Dim exitCode As Long
    AppShellandWait = True
    id = AppShell(inArgs, inWindowAttribute)
    Do
        Call GetExitCodeProcess(ApphProcess, exitCode)
        DoEvents
    Loop While exitCode& > 0
    AppShellandWait = False
End Function



Fri, 05 Jan 2001 03:00:00 GMT  
 
 [ 2 post ] 

 Relevant Pages 

1. Run backround application without being listed among the applications of the windows task manger

2. Run backround application without being listed among the applications of the windows task manger

3. Getting active tasks list in VB

4. After closing my application, Task is active an will not close

5. Checking if an application is still active before sendkeys

6. checking if application is active

7. Check for an active application

8. Urgent: How to check if a VB application is active

9. eVB - Checking if Application is already active

10. eVB - Checking if Application is already active

11. Hiding Application from the task list

12. A Question about the Applications list in Task Manager

 

 
Powered by phpBB® Forum Software