Being notified of app running
-
Hi all, does anyone know hot to be notified if a .exe file start running? I both need it for regular applications and services, too, but I think the solution could be the same. Basically I would need of a signaled event when the monitored .exe is start running for app. I would also need a signaled event when some changes happen in the services controlled by the Service Control Manager. Thanx in advance. Regards, Andrea
-
Hi all, does anyone know hot to be notified if a .exe file start running? I both need it for regular applications and services, too, but I think the solution could be the same. Basically I would need of a signaled event when the monitored .exe is start running for app. I would also need a signaled event when some changes happen in the services controlled by the Service Control Manager. Thanx in advance. Regards, Andrea
There are a lot of methods to do this... here two of them (possibly not the best of them, but the ones I know ;) ) 1. You can use findwindow in time intervals in order to know if your app is there, this is an easy trick, but it can be a problem if your app hungs. 2. your app can lock a dummy file and the others can monitor that file state, if it is locked your app is running... Hope this helps.
-
There are a lot of methods to do this... here two of them (possibly not the best of them, but the ones I know ;) ) 1. You can use findwindow in time intervals in order to know if your app is there, this is an easy trick, but it can be a problem if your app hungs. 2. your app can lock a dummy file and the others can monitor that file state, if it is locked your app is running... Hope this helps.
Hi Joan, unfortunately these solutions have a counterpart: they need CPU time for testing! I need something more efficient... Regards, Andrea
-
Hi Joan, unfortunately these solutions have a counterpart: they need CPU time for testing! I need something more efficient... Regards, Andrea
yes, of course those solutions need CPU, but how do you want to be sure that the app is going on without looking for it often? Imagine that you send a message from your app to the "controller" (I'll call controller to the application that needs to know if your app is active) when your app starts, and another when your app stops... If you can ensure that your app won't hung and that the controller is started before the app, this could be a good solution, think about a button (or something similar in your controller in order to kill the flag (only in case that your app hungs)). Remember not to use FindWindow (if your app can hung, this could make the controller hung also). Think about: what could happen if your controller was not started before the app? For this reason I thought on the file locking method... (that sacrifices some CPU making the controller looking after that, but gives you almost all the control needed. I've used that in order to make two controlling services to know about if my app was running, if my app, or one of the services was stopped the computer immediately stopped... (this was done in a console computer environment (a computer programmed to move a machine)). If you don't need to know about the state of your app. you can use the sending of messages, cheap and easy. Think about a messages protocol that allow the two apps to communicate... hope this helps...