🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: comp.os.ms-windows.programmer.misc
Article #2927

Re: How to avoid multiple instances of a program in NT and 95?

#2927
From: Richard Baldwin
Date: Tue, 04 Feb 1997 00:00
22 lines
1909 bytes
In article <01bc11ec$dfe21120$b8bfabc7@pongo>, Mickey Williams
<mickeyw@deltanet.com> writes
>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.
>
Does this method work under Win32s?
-- 
Richard Baldwin
Technical Details
Message-ID: <3Kq8KAA+ax9yEwPr@ormesci.demon.co.uk>
Path: arc1-ca.pugleaf.net!unknown!not-for-mail
References: <5d4eeb$n6u$1@euler.space.net> <01bc11ec$dfe21120$b8bfabc7@pongo>

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: 113dfb,3403ef0501dd273
X-Google-Attributes: gid113dfb,public
X-Google-Thread: f6ef4,3403ef0501dd273
X-Google-Attributes: gidf6ef4,public
X-Google-Thread: 105df1,3403ef0501dd273
X-Google-Attributes: gid105df1,public
From: Richard Baldwin <richard@ormesci.demon.co.uk>
Subject: Re: How to avoid multiple instances of a program in NT and 95?
Date: 1997/02/04
Message-ID: <3Kq8KAA+ax9yEwPr@ormesci.demon.co.uk>
X-Deja-AN: 214347594
distribution: world
x-nntp-posting-host: ormesci.demon.co.uk
references: <5d4eeb$n6u$1@euler.space.net> <01bc11ec$dfe21120$b8bfabc7@pongo>
organization: Orme Scientific
mime-version: 1.0
newsgroups: comp.os.ms-windows.programmer.misc,comp.os.ms-windows.programmer.win32,de.comp.os.ms-windows.programmer,fido.ger.windows.prog