Old 16th October 2004, 22:46   #1
lopardo2003
Junior Member
 
Join Date: Nov 2002
Location: Argentina
Posts: 38
detecting and closing previous instances

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.
lopardo2003 is offline   Reply With Quote
Old 17th October 2004, 19:16   #2
Joel
Debian user
(Forum King)
 
Joel's Avatar
 
Join Date: Jan 2003
Location: Arch land
Posts: 4,917
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.



* PC: Intel Core 2 DUO E6550 @ 2.33 GHz with 2 GB RAM: Archlinux-i686 with MATE.
* Laptop: Intel Core 2 DUO T6600 @ 2.20 GHz with 4 GB RAM: Archlinux-x86-64 with MATE.
Joel is offline   Reply With Quote
Old 17th October 2004, 19:25   #3
deguix
Major Dude
 
deguix's Avatar
 
Join Date: Dec 2002
Location: Everett - MA, USA
Posts: 1,354
Send a message via ICQ to deguix
FindWindow syntax:

Quote:
FindWindow user_var(hwnd output) windowclass [windowtitle] [windowparent] [childafter]
Example:
code:
FindWindow $0 "#32770" "" $HWNDPARENT

My Wiki Pages

Working now on:
New projects. (language: any)
deguix is offline   Reply With Quote
Old 17th October 2004, 20:45   #4
Afrow UK
Moderator
 
Afrow UK's Avatar
 
Join Date: Nov 2002
Location: Surrey, England
Posts: 8,434
This works nicely:

code:

!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



-Stu
Afrow UK is offline   Reply With Quote
Old 20th October 2004, 19:26   #5
iceman_k
NSIS Dev
 
iceman_k's Avatar
 
Join Date: Feb 2003
Location: Boston, MA, U.S.A.
Posts: 455
If your application is a non-windowed application, use a combo of FindProc and KillProc.
FindProc will tell you if the application is running.
You can then inform the user and use KillProc to kill the process if necessary.

Cheers,
Iceman_K

EclipseNSIS - An NSIS IDE for the Eclipse Platform | My contributions to the wiki
iceman_k is offline   Reply With Quote
Old 25th January 2005, 16:52   #6
YooperNC
Junior Member
 
Join Date: Nov 2003
Location: Raleigh, NC
Posts: 17
Send a message via AIM to YooperNC
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
YooperNC is offline   Reply With Quote
Old 25th January 2005, 17:21   #7
iceman_k
NSIS Dev
 
iceman_k's Avatar
 
Join Date: Feb 2003
Location: Boston, MA, U.S.A.
Posts: 455
Because it is guaranteed to kill the process.
ExitProcess may result in a deadlock.
See ExitProcess.

Cheers,
Iceman_K

EclipseNSIS - An NSIS IDE for the Eclipse Platform | My contributions to the wiki
iceman_k is offline   Reply With Quote
Reply
Go Back   Winamp & Shoutcast Forums > Developer Center > NSIS Discussion

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump