Trap external app exiting?

jenn5175

Active member
Joined
Apr 4, 2002
Messages
35
Is there a way to write a small app that can trap when another process exits? Heres the senerio:

We have a kiosk which always needs to be running this one app (its just an informational promo people at the show click through)

However, whoever made the app put an exit button on it.

We cannot get into the app code to remove the exit button, so I am looking for a way to trap when someone hits the exit button on the promo app and relaunch it automatically. Or possibly disable the App.end command in a global sense so clicking the button would do nothing.

Any ideas would be helpful, not sure where to start or even what keywords I should be searching under. Thanks!!

Jenn
 
Try using Process.GetProcessByName. A Process object has an Exited event, maybe thatll do.

Im not entirely sure, but Ive a feeling you may need special rights on a process to attach to it that way, but Im a little rusty. Its worth a shot.
 
Could you elaborate on how to use showWindow? I do not have access to the source code of the app to hide the button. However, you may be suggesting I build another app to sit on top of the existing exit button. This idea could definatly work. However, if I make this new app always on top, can I ever click through things on the bottom app? Or does "always on top" mean focus must remain on the new app so they could not click buttons on the bottom app?

Or I could have totally missed why you suggested ShowWindow. In which case sorry Im kinda slow and could you give me a little more insight into your idea? Thanks!!

Jenn
 
Youd create a small VB.NET application that would be launched after the kiosk application is started. The VB.NET program would then call [api]ShowWindow[/api], after retrieving the buttons window handle using [api]FindWindowEx[/api], and then terminate. [api]ShowWindow[/api] would only need to be called once, since the button will remain hidden even after the VB.NET application is closed.
 
Thanks - I just played around with it - have never used those functions so it was pretty cool. I got my VB app to work perfectly turning on and off controls on a VB app. However, theres one more wrench to throw in which I just found out about. I just got a copy of the kiosk app and it turns out the app which is running on the kiosk is a Director/Quicktime app. So I kept trying to grab child windows of that and had no luck. The only window I can manipulate is the main window - I cant find a way to distinguish between menu links within that window. Know of a way to do this given the type of file?

Thanks for your help though! It seems like there has to be a Process Watcher type thing similar to FolderWatcher. I wouldnt mind more suggestions if anyone has them!

Jenn
 
In case anyone is searching and wants to know how I ended up accomplishing this, heres the jist - I just started the Director exe from inside my program so I could monitor it. I basically just wait in an infinite loop for it to exit and restart when it does. There may be a better way but this is all I could come up with:

Private Sub Form_Load()
Dim proc As PROCESS_INFORMATION
Dim start As STARTUPINFO
Dim i As Integer

Initialize the STARTUPINFO structure:
start.cb = Len(start)

ret& = CreateProcessA(vbNullString, "c:\corvette2003\support\StartPc.exe", 0&, 0&, 1&, _
NORMAL_PRIORITY_CLASS, 0&, vbNullString, start, proc)
i = 1
Do While i > 0
ret& = WaitForSingleObject(proc.hProcess, INFINITE)
Call CloseHandle(proc.hThread)
Call CloseHandle(proc.hProcess)
ret& = CreateProcessA(vbNullString, "c:\corvette2003\support\StartPc.exe", 0&, 0&, 1&, _
NORMAL_PRIORITY_CLASS, 0&, vbNullString, start, proc)
Loop
End Sub
 
Back
Top