Tracking other processes with Visual Basic 
Author Message
 Tracking other processes with Visual Basic


I'm having no luck in solving a problem that has been bothering me for a

I want to spawn a process from my Visual Basic application, and then monitor
that process to take action when it has completed its run (due to an error
or otherwise)  I have tried many things using various combinations of
shellexecute and watching window handles, with no luck.  Here is where I am

' mark this as a running process
queuePtr.flag = "RUN"

' execute the application
r = ShellExecute(0, "open", queuePtr.executable, queuePtr.params, 0, 1)

queuePtr.hwnd = GetForegroundWindow()
lasthwnd = queuePtr.hwnd

' when the new window for the application pops up, record its handle
While lasthwnd = queuePtr.hwnd
queuePtr.hwnd = GetForegroundWindow()
' I should now have the correct handle in queuePtr.hwnd

Then, using a timer, I would check to see if the handle was gone.  If it
was, I could take appropriate action.

  If current.flag = "RUN" Then
    tmp = IsWindow(current.hwnd)
    If IsWindow(current.hwnd) = 0 Then
        current.flag = "DONE"
    End If

  End If

This doesn't seem to work for me.  Does anyone have an insight into why this
is not working?  Or perhaps a better way to accomplish the same task?
Thanks a lot...

Phil Schaechter

Wed, 18 Jun 1902 08:00:00 GMT  
 [ 1 post ] 

 Relevant Pages 

1. Fast track Visual Basic Training

2. kill a process from visual basic

3. Visual Basic 5: Kill process

4. Visual Basic and image processing

5. Visual Basic and image processing

6. How detect idle of other process with API and Visual basic

7. NT Task Manager process list from Visual Basic ?

8. controlled processes using visual basic

9. Visual BAsic -> COM in-process

10. Trying to process a database within Visual Basic

11. !HELP - Listing and Killing processes and programs in Visual Basic

12. NT Task Manager process list from Visual Basic ?


Powered by phpBB® Forum Software