Re: [GD-Windows] Limiting to one instance
Brought to you by:
vexxed72
From: Daniel V. <Dan...@ep...> - 2006-08-17 19:37:06
|
We're using something close to the below snippet to determine whether the game is already running, in which case we don't write to shared resources like shader caches so running multiple instances works fine for network testing and such. HANDLE NamedMutex =3D CreateMutex( NULL, TRUE, TEXT("UniqueNameForGame") ); if( NamedMutex && GetLastError() !=3D ERROR_ALREADY_EXISTS ) { // We're the first instance! GIsFirstInstance =3D TRUE; } else { // There is already another instance of the game running. GIsFirstInstance =3D FALSE; ReleaseMutex( NamedMutex ); NamedMutex =3D NULL; } Seems to work fine for us. -- Daniel, Epic Games Inc. =20 > -----Original Message----- > From: gam...@li...=20 > [mailto:gam...@li...]=20 > On Behalf Of Wismerhill > Sent: Thursday, August 17, 2006 4:25 AM > To: Game Development for MS Windows > Subject: Re: [GD-Windows] Limiting to one instance >=20 > Some info here: http://www.ddj.com/dept/windows/184416853 >=20 >=20 > 2006/8/15, Research <res...@ga... >: >=20 > Is the preferred method of not allowing multiple=20 > instances of a game to run > at the same to use named mutexes via CreateMutex and=20 > test for it's > exeistence on startup? > =09 > I found an example on MSDN, but it seems targeted at=20 > .NET applications. I'm > not sure if there's an easier way to prevent mutliple=20 > launches for a Win32=20 > app. > =09 > Thanks, > Brett Bibby > GameBrains > =09 > =09 > =09 > -------------------------------------------------------------- > ----------- > Using Tomcat but need to do more? Need to support web=20 > services, security? > Get stuff done quickly with pre-integrated technology=20 > to make your job easier=20 > Download IBM WebSphere Application Server v.1.0.1 based=20 > on Apache Geronimo > =09 > http://sel.as-us.falkag.net/sel?cmd=3Dlnk&kid=3D120709&bid=3D263057& > dat=3D121642=20 > _______________________________________________ > Gamedevlists-windows mailing list > Gam...@li... > =09 > https://lists.sourceforge.net/lists/listinfo/gamedevlists-wind > ows=20 > <https://lists.sourceforge.net/lists/listinfo/gamedevlists-windows>=20 > Archives: > http://sourceforge.net/mailarchive/forum.php?forum_id=3D555 > =09 >=20 >=20 >=20 |