RE: [email] RE: Restarting game exe

"Jon Watte" <[email protected]> Wed, 8 Sep 2004 22:14:04 -0700
Newsgroups gmane.games.devel.windows
Message-ID <[email protected]>
hPrevInstance is only available under the Win16 execution
environment, as far as I know.

You can create a global Event or other named primitive in
exclusive-named mode, and if that fails, some other process
already created the thing. On NT-based kernels, cleaning up
of named primitives when processes go away is pretty solid.
(I'll let you work out what I actually implied when saying
that :-) This is often used to prevent multiple execution
of an application.

Using OpenHandle() will fail if the event is not already
created. You could use this to hand-shake between the two
processes, and then get a handle to the starting process
and wait on that to complete.

You can use OpenProcess() followed by GetExitCodeProcess()
to poll for another process to complete, or just pass the
process handle to WaitForSingleObject( , INFINITE );

Cheers,

			/ h+

-----Original Message-----
From: [email protected]
[mailto:[email protected]]On Behalf Of
Dan Thompson
Sent: Wednesday, September 08, 2004 6:29 PM
To: [email protected]
Subject: Re: [email] RE: [GD-Windows] Restarting game exe


Haven't tried this, but I'm sure there's a way to spin on the previous
HINSTANCE that is passed in on WinMain - that is, if you are worried about
dual execution.

Something like
if (hPrevInstance != NULL)
{
    // Can't remember what to use to get the module handle.
    // You may be able to just straight up do
    WaitForSingleObject(hPrevInstance, 100 /*timeout in case the other
doesn't exit*/ );

    // But that doesn't feel right. (be sure to check for timeout, in case
the
    // user actually executed it twice
}

Something like that. There's probably a few steps to get the correct handle
to Wait() on.

-Dan

----- Original Message -----
From: "George Geczy (BattleGoat) (E-mail)" <[email protected]>
To: <[email protected]>
Sent: Wednesday, September 08, 2004 6:05 PM
Subject: [email] RE: [GD-Windows] Restarting game exe


> Yeah, CreateProcess() was on the list of possibles (that and
ShellExecute(),
> though the latter is not available in Win98).  It just seems a bit
kludgy -
> ie, for an unknown amount of time you have two instances of your game
> running, depending upon how Windows dishes out the execution.
>
> Maybe that's why I couldn't find a better way - there is no better way :-)
>
> -- George.
>
>
> - George Geczy
> - Lead Programmer, BattleGoat Studios
> - www.supremeruler2010.com
> - "Designing the Next Generation of Intelligent Strategy Games"
>
>
>
> > -----Original Message-----
> > From: [email protected]
> > [mailto:[email protected]]On Behalf Of
> > Jon Watte
> > Sent: Wednesday, September 08, 2004 5:45 PM
> > To: [email protected]
> > Subject: RE: [GD-Windows] Restarting game exe
> >
> >
> >
> > Get your EXE path by getting the module path of your main module.
> >
> > Then use CreateProcess() to create the new process, and
> > ExitProcess() your
> > current process.
> >
> > If you're looking for "exec()" then there might be emulation
> > of that, but
> > the basic NT kernel primitive is somewhat different, so it
> > won't be quite
> > what you'd be used to from UNIX.
> >
> > Cheers,
> >
> > / h+
> >
>
>
>
> -------------------------------------------------------
> This SF.Net email is sponsored by BEA Weblogic Workshop
> FREE Java Enterprise J2EE developer tools!
> Get your free copy of BEA WebLogic Workshop 8.1 today.
> http://ads.osdn.com/?ad_id=5047&alloc_id=10808&op=click
> _______________________________________________
> Gamedevlists-windows mailing list
> [email protected]
> https://lists.sourceforge.net/lists/listinfo/gamedevlists-windows
> Archives:
> http://sourceforge.net/mailarchive/forum.php?forum_id=555
>



-------------------------------------------------------
This SF.Net email is sponsored by BEA Weblogic Workshop
FREE Java Enterprise J2EE developer tools!
Get your free copy of BEA WebLogic Workshop 8.1 today.
http://ads.osdn.com/?ad_id=5047&alloc_id=10808&op=click
_______________________________________________
Gamedevlists-windows mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/gamedevlists-windows
Archives:
http://sourceforge.net/mailarchive/forum.php?forum_id=555



-------------------------------------------------------
This SF.Net email is sponsored by BEA Weblogic Workshop
FREE Java Enterprise J2EE developer tools!
Get your free copy of BEA WebLogic Workshop 8.1 today.
http://ads.osdn.com/?ad_id=5047&alloc_id=10808&op=click
_______________________________________________
Gamedevlists-windows mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/gamedevlists-windows
Archives:
http://sourceforge.net/mailarchive/forum.php?forum_id=555