Thread: [GD-Windows] Limiting to one instance
Brought to you by:
vexxed72
|
From: Research <res...@ga...> - 2006-08-15 06:17:18
|
Is the preferred method of not allowing multiple instances of a game to run at the same to use named mutexes via CreateMutex and test for it's exeistence on startup? I found an example on MSDN, but it seems targeted at .NET applications. I'm not sure if there's an easier way to prevent mutliple launches for a Win32 app. Thanks, Brett Bibby GameBrains |
|
From: Mat N. \(BUNGIE\) <Mat...@mi...> - 2006-08-15 06:39:38
|
You'll need a way to synchronize multiple instances of an app; you can = either use shared memory or a mutex. =20 MSN ________________________________ From: gam...@li... on behalf of = Research Sent: Mon 8/14/2006 11:14 PM To: Gam...@li... Subject: [GD-Windows] Limiting to one instance Is the preferred method of not allowing multiple instances of a game to = run at the same to use named mutexes via CreateMutex and test for it's exeistence on startup? I found an example on MSDN, but it seems targeted at .NET applications. = I'm not sure if there's an easier way to prevent mutliple launches for a = Win32 app. Thanks, Brett Bibby GameBrains -------------------------------------------------------------------------= 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 |
|
From: Scoubidou944 \(Hotmail\) <sco...@ho...> - 2006-08-15 08:48:59
|
void main (void)
{
HANDLE hMutex;
hMutex = ::CreateMutex (NULL, TRUE, "MyMutexName");
if ((hMutex == NULL) || (::GetLastError() ==ERROR_ALREADY_EXISTS))
{
// Can't create mutex, another instance running
return;
}
// Continue init
// [...]
// End, release handle
::CloseHandle (hMutex);
}
|
|
From: Dan T. <da...@ar...> - 2006-08-15 16:09:41
|
You have to prefix "Local\" in order to allow for multiple concurrent
users. However if you still run on 9x, you have to remove the Local as
its reserved or somesuch.
-Dan
Scoubidou944 (Hotmail) wrote:
> void main (void)
> {
> HANDLE hMutex;
> hMutex = ::CreateMutex (NULL, TRUE, "MyMutexName");
> if ((hMutex == NULL) || (::GetLastError() ==ERROR_ALREADY_EXISTS))
> {
> // Can't create mutex, another instance running
> return;
> }
>
> // Continue init
> // [...]
>
> // End, release handle
> ::CloseHandle (hMutex);
> }
>
> -------------------------------------------------------------------------
> 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=lnk&kid=120709&bid=263057&dat=121642
> _______________________________________________
> Gamedevlists-windows mailing list
> Gam...@li...
> https://lists.sourceforge.net/lists/listinfo/gamedevlists-windows
> Archives:
> http://sourceforge.net/mailarchive/forum.php?forum_id=555
>
>
>
|
|
From: Wismerhill <wis...@gm...> - 2006-08-17 08:24:59
|
Some info here: http://www.ddj.com/dept/windows/184416853 2006/8/15, Research <res...@ga...>: > > Is the preferred method of not allowing multiple instances of a game to > run > at the same to use named mutexes via CreateMutex and test for it's > exeistence on startup? > > I found an example on MSDN, but it seems targeted at .NET applications. > I'm > not sure if there's an easier way to prevent mutliple launches for a Win32 > app. > > Thanks, > Brett Bibby > GameBrains > > > ------------------------------------------------------------------------- > 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=lnk&kid=120709&bid=263057&dat=121642 > _______________________________________________ > Gamedevlists-windows mailing list > Gam...@li... > https://lists.sourceforge.net/lists/listinfo/gamedevlists-windows > Archives: > http://sourceforge.net/mailarchive/forum.php?forum_id=555 > |
|
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
|