only one instance of an exe?
-
Run it on a very small computer... ... or, check J.M.Newcomers (IIRC) exellent article (here on CP), or, search this forum for CreateMutex and you'll get some tips.
-
Create a named mutex object when your app starts up. In your second app, if another mutex exists with that name, then exit the program. This is how VB implements their version of this.
-
Run it on a very small computer... ... or, check J.M.Newcomers (IIRC) exellent article (here on CP), or, search this forum for CreateMutex and you'll get some tips.
ROFLMAO :-O
"Never tell people how to do things. Tell them what to do, and they will surprise you with their ingenuity." - General George S. Patton Jr.
-
Create a named mutex object when your app starts up. In your second app, if another mutex exists with that name, then exit the program. This is how VB implements their version of this.
kilowatt wrote: This is how VB implements their version of this. I didnt know that. How is it done from VB? Nish
Oh, I don't know why she's leaving, or where she's gonna go I guess she's got her reasons but I just don't wanna know 'Cos for 24 years I've been living next door to Alice 24 years just waitin' for a chance To tell her how I feel and maybe get a second glance Now I gotta get used to not living next door to Alice
-
ROFLMAO :-O
"Never tell people how to do things. Tell them what to do, and they will surprise you with their ingenuity." - General George S. Patton Jr.
No - seriously - this Newcomer guy is good!
-
kilowatt wrote: This is how VB implements their version of this. I didnt know that. How is it done from VB? Nish
Oh, I don't know why she's leaving, or where she's gonna go I guess she's got her reasons but I just don't wanna know 'Cos for 24 years I've been living next door to Alice 24 years just waitin' for a chance To tell her how I feel and maybe get a second glance Now I gotta get used to not living next door to Alice
kilowatt wrote: This is how VB implements their version of this. I didnt know that. How is it done from VB? Forget about it! Even if this is the "offical" way to do it, it has some bad limitations, especially in NTs multiuser/multidesktop environment. I strongly recommend to read the excellent article from Joseph which shows everything about this topic. Some ready to use C-Code can that takes account of this problems can be found here. -- Daniel Lohmann http://www.losoft.de
-
kilowatt wrote: This is how VB implements their version of this. I didnt know that. How is it done from VB? Nish
Oh, I don't know why she's leaving, or where she's gonna go I guess she's got her reasons but I just don't wanna know 'Cos for 24 years I've been living next door to Alice 24 years just waitin' for a chance To tell her how I feel and maybe get a second glance Now I gotta get used to not living next door to Alice
You reference the
app
object and test the hPrevInstance variable. It will return true if there is an previous instance of the app, false if there is not.If (App.PrevInstance) Then
MsgBox "Previous Instance Found"
Else
MsgBox "No Previous Instance"
End IfBasically this feature is implemented internally with the named mutex as I mentioned earlier in the thread.
-
kilowatt wrote: This is how VB implements their version of this. I didnt know that. How is it done from VB? Forget about it! Even if this is the "offical" way to do it, it has some bad limitations, especially in NTs multiuser/multidesktop environment. I strongly recommend to read the excellent article from Joseph which shows everything about this topic. Some ready to use C-Code can that takes account of this problems can be found here. -- Daniel Lohmann http://www.losoft.de
I think Nish was simply asking how you get access to the previous instance feature in VB. I don't think that just because VB implements it this way, that says this is the "official" way to do it.
-
This is what I use. /ravi "There is always one more bug..." http://www.ravib.com ravib@ravib.com
-
create a static instance for a type ex: static CMyClass *pInstance; // you need to initialize it... CMyClass *CMyClass::pinstance = NULL; add the following functions // constructing the object CMyClass *CMyClass::GetInstance() { if(pInstance== NULL) pInstance = new CMyClass; return pInstance; } // destructing the object void CSystemManager::DeleteInstance() { if( pInstance) delete pInstance; pInstance = NULL; } apart from constructor and destructor... Now... you can happily access the singleton thro GetInstance() function. call DeleteInstance() when you are done with that. -anu