Re: [GD-Windows] Limiting to one instance
Brought to you by:
vexxed72
From: Stefan B. <Ste...@di...> - 2006-08-15 08:52:36
|
But you don't need a global mutex, just a named session mutex, no? = I.e. just a plain named Mutex (without \\global\ prefix) will do if you = want the mutex to apply only to the current user session. /Stefan > -----Original Message----- > From: gam...@li... > [mailto:gam...@li...] On Behalf = Of > Dirk Ringe > Sent: 15 August 2006 10:22 > To: Alen Ladavac; Game Development for MS Windows; Andrew Grant > Subject: Re: [GD-Windows] Limiting to one instance >=20 > One thing to keep in mind when using global objects in windows is Fast > User Switching in Windows XP, where in fact multiple users are logged = in > at the same time. When you use CreateMutex you block the application = from > running under ALL other user accounts as well. This could as well = apply to > FindWindow. If you do not want this to happen, you have to use a = technique > which is per user, like the old unix style pid file stored under the = users > home directory. >=20 > Dirk >=20 > -----Urspr=FCngliche Nachricht----- > Von: gam...@li... > [mailto:gam...@li...] Im Auftrag = von > Alen Ladavac > Gesendet: Dienstag, 15. August 2006 10:13 > An: Andrew Grant > Cc: Game Development for MS Windows > Betreff: Re: [GD-Windows] Limiting to one instance >=20 > > I remember at an old company one genius tried to prevent multiple > instances > > of an app by binding a port, and was then surprised when it failed = for > > pretty much everyone who was running a firewall! >=20 > Actually, it's not such a weird idea. Some applications rely on IP > ports as a simple yet very portable IPC mechanism. Firewalls should > really know better, by handling 127.0.0.1 specifically by default. But > apparently even the best in class don't. >=20 > Btw, in my book, even using a named mutex in that way is a bit hacky > because you are relying on error. But what can we do, when there's no > real API intended for that purpose. >=20 > Personally, I've been using FindWindow(xyz, NULL) to find a main > window by class name. Same principle (with same weaknesses as a named > mutex), but doesn't require an extra object creation, as you probably > already have a window, and you can use this to test even for foreign > applications, because it doesn't require access to the code of the > tested application. A nice side effect is that once you have the > window, you can report messages like "Cannot start, please close ABCD > application first", where you get the ABCD from the application's main > window caption. >=20 > Cheers, > Alen >=20 >=20 > = -------------------------------------------------------------------------= > Using Tomcat but need to do more? Need to support web services, = security? > Get stuff done quickly with pre-integrated technology to make your job > easier > Download IBM WebSphere Application Server v.1.0.1 based on Apache = Geronimo > = http://sel.as-us.falkag.net/sel?cmd=3Dlnk&kid=3D120709&bid=3D263057&dat=3D= 121642 > _______________________________________________ > Gamedevlists-windows mailing list > Gam...@li... > https://lists.sourceforge.net/lists/listinfo/gamedevlists-windows > Archives: > http://sourceforge.net/mailarchive/forum.php?forum_id=3D555 >=20 >=20 >=20 > = -------------------------------------------------------------------------= > Using Tomcat but need to do more? Need to support web services, = security? > Get stuff done quickly with pre-integrated technology to make your job > easier > Download IBM WebSphere Application Server v.1.0.1 based on Apache = Geronimo > = http://sel.as-us.falkag.net/sel?cmd=3Dlnk&kid=3D120709&bid=3D263057&dat=3D= 121642 > _______________________________________________ > Gamedevlists-windows mailing list > Gam...@li... > https://lists.sourceforge.net/lists/listinfo/gamedevlists-windows > Archives: > http://sourceforge.net/mailarchive/forum.php?forum_id=3D555 |