Archive: Closing an Application if running


Closing an Application if running
Can anyone explain how to, if possible, detect if an application is running (I have seen ways of detecting Windows, but what if it has no window - systray icon only), and if so, stop it.

I'm trying to create an AutoUpdate thingy if possible.

Thanks!


Hmmm, I seem to repeat myself :( :

Search the Forum and find for instance:
http://forums.winamp.com/showthread....threadid=87330

Please everyone search the Forum before posting. A lot of questions have already been answered! Check this out!

-Hendri.


Message to the systray icon goes to a window proc of the window that it belongs to. The window can be hidden but it is there. You need to find the name or the class name of the window that this icon belongs to and then send it WM_CLOSE.

You can find some usuful info in the post Smile2Me sent you.


Thanks!
The Kill WA3 function worked just fine, thanks guys!!


Which one worked? I hope you didn't use TerminateProcess, it is pretty brutal and unwanted.


Hi Amir

I used the FindWindow and SendMessage to close it and it worked great.

I have nearly completed an online updater (my first decent project with NSIS).

It will:


- close the app if still running (actually it will wait for 1 app to stop, then it will close another itself and continue)
- Check existing versions and write to CURversions.ini
- Download NEWVersions.ini and compare
- Download files as needed (zip2exe's with no popups)
- Extract to their locations (Reg and UnReg DLL's as required)
- Run the app again when done

etc, etc.

It still needs improvement I'm sure!

My only concern is how do I ensure they have an internet connection. Will the downloader invoke the default connection if required? (I'm thinking of Dialup's).

I read another post on this subject where someone was developing a DLL to do this, and had proxy support as well, but the thread died in July last year....I'll send them a message and see if it got finished. The only thing I didn't like was that it prompted for the Updates to continue and stuff. My solution is to be automated. It would be easy to add an ini entry to set if you want prompted before updating!!

I have attached my .nsi and the CURVersions.ini for anyone to see and comment on.

Thanks for all your help Amir, and everyone else!!