Re: Limiting to one instance
"Daniel Vogel" <[email protected]> Thu, 17 Aug 2006 15:36:42 -0400
| Newsgroups | gmane.games.devel.windows |
|---|---|
| Message-ID | <[email protected]> |
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 = CreateMutex( NULL, TRUE, TEXT("UniqueNameForGame")
);
if( NamedMutex && GetLastError() != ERROR_ALREADY_EXISTS )
{
// We're the first instance!
GIsFirstInstance = TRUE;
}
else
{
// There is already another instance of the game running.
GIsFirstInstance = FALSE;
ReleaseMutex( NamedMutex );
NamedMutex = NULL;
}
Seems to work fine for us.
-- Daniel, Epic Games Inc.
> -----Original Message-----
> From: [email protected]
> [mailto:[email protected]]
> 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
>
> Some info here: http://www.ddj.com/dept/windows/184416853
>
>
> 2006/8/15, Research <[email protected] >:
>
> 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
> [email protected]
>
> https://lists.sourceforge.net/lists/listinfo/gamedevlists-wind
> ows
> <https://lists.sourceforge.net/lists/listinfo/gamedevlists-windows>
> Archives:
> http://sourceforge.net/mailarchive/forum.php?forum_id=555
>
>
>
>
-------------------------------------------------------------------------
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
[email protected]
https://lists.sourceforge.net/lists/listinfo/gamedevlists-windows
Archives:
http://sourceforge.net/mailarchive/forum.php?forum_id=555