Article View: comp.os.ms-windows.programmer.misc
Article #2925Re: How to avoid multiple instances of a program in NT and 95?
From: Mickey Williams
Date: Mon, 03 Feb 1997 00:00
Date: Mon, 03 Feb 1997 00:00
21 lines
1790 bytes
1790 bytes
Alois Buecherl <Alois.Buecherl@terraSat.de> wrote in article <5d4eeb$n6u$1@euler.space.net>... > Hello, > I've been striving for so long now to find a SAVE way to start only one > instance of my C++ program under Windows NT and 95. As you might recall, this > used to be that easy in Windows 3.1 using the prevInstance variable. Now this > option is gone. > I've tried using a semaphore that get's locked when the programm's up. But > it still can happen, that the program starts up more than once when multiple > prgram spawns occur very rapidly. The program then did not get enough > startup-time to create and lock the semaphore. > Is there ANY solution to this problem? Create a mutex when your program starts up. GetLastError will return ERROR_ALREADY_EXISTS if the mutex name is already created. -- Mickey Williams Co Author - Programming Windows NT Unleashed Author - Essential Visual C++, Develop a Professional Visual C++ Application in 21 Days
Technical Details
Message-ID:
<01bc11ec$dfe21120$b8bfabc7@pongo>Path:
arc1-ca.pugleaf.net!unknown!not-for-mailReferences:
<5d4eeb$n6u$1@euler.space.net>Show Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 1124cf,3403ef0501dd273 X-Google-Attributes: gid1124cf,public X-Google-Thread: f6ef4,3403ef0501dd273 X-Google-Attributes: gidf6ef4,public X-Google-Thread: 105df1,3403ef0501dd273 X-Google-Attributes: gid105df1,public X-Google-Thread: 113dfb,3403ef0501dd273 X-Google-Attributes: gid113dfb,public From: "Mickey Williams" <mickeyw@deltanet.com> Subject: Re: How to avoid multiple instances of a program in NT and 95? Date: 1997/02/03 Message-ID: <01bc11ec$dfe21120$b8bfabc7@pongo> X-Deja-AN: 214146572 references: <5d4eeb$n6u$1@euler.space.net> organization: Delta Internet Services, Anaheim, Ca newsgroups: comp.os.ms-windows.programmer.misc,comp.os.ms-windows.programmer.win32,de.comp.os.ms-windows.programmer,fido.ger.windows.prog