Hi. I've searched about this in many places but couldn't find anything useful. So, how can I detect and close previous instances of my application from the NSIS installer, just like the Winamp installer does?
Thanks a lot.
detecting and closing previous instances
7 posts
Did you try it with FindWindowEx API?
There you can use your CLASS to dectect your Application?
Winamp uses FindWindow API with the parameter "Winamp v1.0" as the window title.
Maybe you should do that, too.
🙂
There you can use your CLASS to dectect your Application?
Winamp uses FindWindow API with the parameter "Winamp v1.0" as the window title.
Maybe you should do that, too.
🙂
FindWindow syntax:
FindWindow user_var(hwnd output) windowclass [windowtitle] [windowparent] [childafter]Example:
FindWindow $0 "#32770" "" $HWNDPARENT
This works nicely:
-Stu
!define Title "MapUpdater"
!define Version "v0.2b"
Function .onInit
## Check MapUpdater is not already running
Push $R0
FindWindow $R0 "" "${Title} ${Version}" $HWNDPARENT
StrCmp $R0 0 +3
MessageBox MB_OK|MB_ICONSTOP "${Title} is already running!"
Quit
Pop $R0
FunctionEnd
I read the warning in the KillProc description, and now I have a question: Why use TerminateProcess when ExitProcess sounds like it would be the prefered method?
Thanks.
Dave
Thanks.
Dave
Because it is guaranteed to kill the process.
ExitProcess may result in a deadlock.
See ExitProcess.
ExitProcess may result in a deadlock.
See ExitProcess.