JamesKiller
24th January 2007 18:20 UTC
[Help]how to detect a program is running?
Hi All,
I have installed my application (named myApp.exe, it is windows Form application),however, when I try to unistall this application. How can I detect if this program is running, normally we will to do this:
when uninstalling, if detecting this application is running, we should force to close it.(At least close the window, don't want users to use anymore). Then we delete this file right away, don't wait till reboot the computer.
So how to detect program running in NSIS,if found,how to force to close it down so that we can delete the files right away!
Please help me out so that i can meet the project deadline.
Thank you very much.
James
Red Wine
24th January 2007 18:31 UTC
A similar recent thread,
http://forums.winamp.com/showthread....hreadid=262969
JamesKiller
24th January 2007 18:53 UTC
But it seems that they are using one plugin dll file, when can i download it to test?
Red Wine
24th January 2007 19:12 UTC
Like every nsis plugin at wiki,
http://nsis.sourceforge.net/Developer_Center
JamesKiller
24th January 2007 20:08 UTC
Thank you , Red Wine.
One more thing, I can detect the program running, how can I kill it (just force to close the window). Then i can delete the exe and dll files....
Red Wine
24th January 2007 20:17 UTC
I think the idea of the author on the above thread (pop up a custom page or a message box and ask users to terminate the application before uninstall) is the right way to go.
If you anyway wish to kill it, you may do it either by FindWindow and SendMessage or with NsProcess plugin,
http://nsis.sourceforge.net/NsProcess_plugin
Brummelchen
24th January 2007 21:17 UTC
http://forums.winamp.com/showthread....hreadid=259546
humm - forget it... (Update)
"Processes::FindProcess" / "Processes::KillProcess" do it same way, or "fct"
JamesKiller
24th January 2007 22:04 UTC
Yeah. Thank you guys. I have don't this part.....Cheers.
one more stuip question:
how can i make one function then both install and uninstall can call it.
Red Wine
24th January 2007 22:11 UTC
There you are :)
http://nsis.sourceforge.net/Macro_vs_Function
JamesKiller
24th January 2007 22:44 UTC
Red Wine,
you are the rock. Thank you very very much.......
James
Red Wine
24th January 2007 23:04 UTC
Indeed :) I've been in Woodstock...
Takhir
25th January 2007 08:19 UTC
NsProcess based on the KillProcDLL, so MSDN warning touchs both plug-ins:
The TerminateProcess function is used to unconditionally cause a process to exit. Use it only in extreme circumstances. The state of global data maintained by dynamic-link libraries (DLLs) may be compromised if TerminateProcess is used rather than ExitProcess.
If your application has window Find-Close-Terminate would be better.