Web Images News Groups Books Scholar Google Mail more »
Recently Visited Groups | Help | Sign in
Google Groups Home
Message from discussion Stop access database being opened a second time

View parsed - Show only message text

Reply-To: "Mike Labosh" <mlab...@hotmail.com>
From: "Mike Labosh" <mlab...@hotmail.com>
References: <#GHcNut3EHA.208@TK2MSFTNGP12.phx.gbl>
Subject: Re: Stop access database being opened a second time
Date: Fri, 10 Dec 2004 12:54:22 -0500
Lines: 25
Organization: vbSensei.Com
X-Priority: 3
X-MSMail-Priority: Normal
X-Newsreader: Microsoft Outlook Express 6.00.2900.2180
X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2900.2180
X-RFC2646: Format=Flowed; Response
Message-ID: <OMlJLFu3EHA.1292@TK2MSFTNGP10.phx.gbl>
Newsgroups: microsoft.public.access
NNTP-Posting-Host: 12.104.126.52
Path: g2news1.google.com!news3.google.com!news.glorb.com!cyclone1.gnilink.net!gnilink.net!wn14feed!worldnet.att.net!204.71.34.3!newsfeed.cwix.com!TK2MSFTNGP08.phx.gbl!TK2MSFTNGP10.phx.gbl

>    If a user already has my frontend opened on their pc, I want a message 
> to appear when they open it a second time. How can I check for this?

A Mutex Question!  These are always fun!

"Mutex" stands for "Mutually Exclusive".  In the WIN32 API SDK, a Mutex is a 
system-level resource that can only be held by one process.  To accomplish 
what you want, you can have your startup code create a mutex with a specific 
hard-coded name, and hold the Mutex's handle in a public global variable. 
Then your shutdown code passes that handle back to windows to release it. 
Then, when a user starts a second instance of your application, the new call 
to CreateMutex() fails, and you can MsgBox the user and quit.  The only 
catch is that if you're in the VBA debugger and "reset" your code, you lose 
the mutex handle and will be unable to release it.  Lookup these two 
functions in MSDN:

CreateMutex()
ReleaseMutex()
-- 
Peace & happy computing,

Mike Labosh, MCSD
"I have no choice but to believe in free will." 



Create a group - Google Groups - Google Home - Terms of Service - Privacy Policy
©2009 Google