Re: Checking for another instance of an application
From: Björn Holmgren (bjohol_at_hotmail.com)
Date: 04/01/04
- Next message: Pásztor, Zoltán: "Re: Is it possible to delete an object in vb in such a way that using that object will cause an error?"
- Previous message: Neem: "Re: Is it possible to delete an object in vb in such a way that using that object will cause an error?"
- In reply to: Ken Halter: "Re: Checking for another instance of an application"
- Next in thread: Larry Serflaten: "Re: Checking for another instance of an application"
- Reply: Larry Serflaten: "Re: Checking for another instance of an application"
- Reply: Gary T. H. Novosel: "Re: Checking for another instance of an application"
- Messages sorted by: [ date ] [ thread ]
Date: Thu, 1 Apr 2004 12:51:45 +0200
The problem with App.Previnstance is that it will only return true if you
start the same exe twice from the exact same location. If the exe resides in
different locations or if it's started using a different path notation,
previnstance will return false.
Try this:
1) Put your exe file on a network share
2) Map a drive to the share
3) Start the app using the mapped path (ie H:\MyApp.exe)
4) Now start another instance using the UNC path (ie
\\MyServer\MyShare\MyApp.exe)
App.Previnstance will return False because the second app is started using a
"different" path.
Personally, I prefer using a named mutex (see BeastFish's reply), but
needless to say, you must come up with a unique name. Generating a GUID for
your app and using that to name the mutex is a good idea.
One problem with the mutex approach is that you need to write code to bypass
the instance checking when run from within the IDE. The reason for this is
that the mutex isn't removed until VB6.EXE is terminated.
-- Björn Holmgren Guide Konsult AB "Ken Halter" <Ken_Halter@Use_Sparingly_Hotmail.com> wrote in message news:#TRt#W0FEHA.2976@TK2MSFTNGP10.phx.gbl... > The basics.... check if App.PrevInstance = True. If so, there's another > instance. If that's not enough, there are tons of ways to do it but all > involve pages of API calls. > > -- > Ken Halter - MS-MVP-VB - http://www.vbsight.com > Please keep all discussions in the groups.. > "Gary T. H. Novosel" <novosel-g@northnet.org> wrote in message > news:uVIK8%23zFEHA.2404@TK2MSFTNGP11.phx.gbl... > How do I go about seeing if there is another instance of my application > already running on a system? I want to limit the application to run only a > single instance at a time. > > Thanks. > > Gary > > -- > Gary Novosel > > The are 10 types of people in the world, those who understand binary and > those who do not. > >
- Next message: Pásztor, Zoltán: "Re: Is it possible to delete an object in vb in such a way that using that object will cause an error?"
- Previous message: Neem: "Re: Is it possible to delete an object in vb in such a way that using that object will cause an error?"
- In reply to: Ken Halter: "Re: Checking for another instance of an application"
- Next in thread: Larry Serflaten: "Re: Checking for another instance of an application"
- Reply: Larry Serflaten: "Re: Checking for another instance of an application"
- Reply: Gary T. H. Novosel: "Re: Checking for another instance of an application"
- Messages sorted by: [ date ] [ thread ]
Relevant Pages
|