|
|
#1 |
|
Junior Member
Join Date: Nov 2008
Location: Paris
Posts: 4
|
$(^Name) and MUI
Hi,
I try to use the code from [1] to not allow 2 installers to run at the same time. The problem is that it uses $(^Name) to the window name. But I also use MUI, so window name changes according to the current page ("Language Installer", "Installation de XXX", ...) So my question is: Is it possible to get all those window names from MUI so I can test them all to detect if installer is already running? Thanks for your help, Asterix [1] http://nsis.sourceforge.net/Games_Ex...nce_at_a_time. |
|
|
|
|
|
#2 |
|
Major Dude
Join Date: Jun 2001
Posts: 1,173
|
A much easier solution is to simply define your installer's name yourself as something unique and fixed.
code: And then replace ${^Name} in the mutex code with ${myAppName} |
|
|
|
|
|
#3 |
|
Junior Member
Join Date: Nov 2008
Location: Paris
Posts: 4
|
Will it really work? I mean user32::GetWindowText will return ${myAppName} ? I thought it returns window name ...
|
|
|
|
|
|
#4 |
|
Major Dude
Join Date: Jun 2001
Posts: 1,173
|
Don't use GetWindowText at all. You're just using a string (-any- string) and using windows' APIs to create a mutex. If you try to create a mutex with that same string, windows will return an error.
Thus in its simplest form: code: |
|
|
|
|
|
#5 |
|
Junior Member
Join Date: Nov 2008
Location: Paris
Posts: 4
|
ok, this is the first code of the example, but I like the second example that gives focus to the first installer when I run a second one. But for that, I need the window instance. In the example it's done by cycling on all NSIS windows and looking at its name. There is no problem if there is only one installer running, but if there are others you could give focus to the wrong one.
|
|
|
|
|
|
#6 |
|
Major Dude
Join Date: Jun 2001
Posts: 1,173
|
Well if finding the window (to give it focus) is the main issue, then we can ignore the mutex stuff
![]() You could... - just hard code the various page titles, and test for each of the titles (lots of work and requires you to make sure each page title still fits any time you change your installer) - prefix the page titles with a presumably unique string, in the existing script, this code.. code: Will then become something like code: Very little work, and this is mostly maintenance-free, as long as you keep your prefix the same. - let your installer write to the registry that it is running, and under what title (or maybe hwnd, as an integer), it can be found. That way you can just read that out directly. This is a bit more work than the prefix method, but is somewhat more future-proof; if you don't like your page titles prefixed / or change the prefix in the future, that method will break - while your registry location probably wouldn't change. This does mean registry i/o where it's not strictly necessary. Ideally you'd somehow figure out who owns a mutex you're trying to create and which failed - but I don't think there's a way within the mutex object itself.. |
|
|
|
|
|
#7 |
|
Junior Member
Join Date: Nov 2008
Location: Paris
Posts: 4
|
I don't know how to access MUI window name (that was my first question) But I don't like the idea to prefix those names.
registery sounds a better solution, but there are several windows, so I have to change the hwnd when a new one open, and once again I don't know how to access it. But that sounds too hard to achieve. So I'll stick with my simple solution, to focus the first NSIS installer. Most likely there will be only one. Thanks a lot for your help though. |
|
|
|
|
|
#8 |
|
Major Dude
Join Date: Jun 2001
Posts: 1,173
|
code: Example use: code: But you don't want prefixes, so that wouldn't help much. As for the window handle thingy (hwnd) code: Shouldn't change at all - for a single installer.. unless you're launching different installers throughout the installation.. which would be weird. And there should be only one installer running, given that you wouldn't allow more than 1 installer to run at the same time (what all this code is partly about, no?) |
|
|
|
![]() |
|
|||||||
| Thread Tools | Search this Thread |
| Display Modes | |
|
|