Talk:How to check whether the application is running
Many a times it is required to identify if an application is running or not. This code snippet provides static function for checking the same. It is a very simple and straight forward example and is self explanatory.
Izinin - MySystemUtils::IsApplicationRunningL implementation is incorrect
TBool situationFlag = apatask.Exists();
Above check for application running is incorrect because according to documentation:
"Tests whether this TApaTask object is empty. This object represents the state of the task at the time at which it was constructed and is not subsequently updated. Therefore, this does not indicate that the task itself exists and should not be used to test whether or not a particular task is running or not. "thus this function will return 'true' even application of interest has already exited (verified)
15:34, 22 December 2011 (EET)
Hamishwillee - @Izinin - how would you do this then?
I think this works because the TApaTaskList only returns running applications - so if you find the app you're after in the list and the state is running then it is running. You'd have a problem if you cached the value though.In any case, IsExeRunning should work for apps as well as other exes.
06:56, 3 January 2012 (EET)