VB6 - Process Exit Event?
Posted on 2006-07-07
Due to constraints within our company, we are rewriting a VB.NET component in VB6. Our component watches a process to see when it is closed by the user (or by other means). In VB.NET, we used the Process Class to attach to a running process and then caught the "Process.Exited" event thrown when the process ended. Is there a similar event in VB6?
Our program spawns a launcher, which then spawns another process. We want to wait for the 3rd process to exit, and then throw an event. For example, our Process (Process A) shell's off Process B (3rd party), which then creates Process C. When process C exits, we need to throw an event from Process A. Right now, we are using a loop to constantly check when the process exits, but this causes too much processor usage for no reason. Currently, our main method looks like the following:
Public Sub RunShell(FileName As String, ProcessToWatch As String)
Dim idProg As Long, iExit As Long, iProc As Long
idProg = Shell(FileName, 1)
iExit = WaitOnShell(idProg)
If Not iExit Then
iExit = WaitOnShellByName(ProcessToWatch)
If Not iExit Then RaiseEvent OnExit
Is there something similar to "Process.Exited" in VB6, and how can I use it?