Re: Single Instance Limit
- From: "MikeD" <nobody@xxxxxxxxxxx>
- Date: Tue, 22 Sep 2009 23:05:09 -0400
"xytsrm" <xytsrm@xxxxxxxxxxxxxxxxxxxxxxxxx> wrote in message news:39F295E1-2883-4E96-A7FE-400FC18FF7AE@xxxxxxxxxxxxxxxx
Is there a way to compile a VB6 app so that it can only run as a single
instance under XP?
It's not a matter of compiling. It's a matter of writing code to handle it. It's also not a matter of "XP" versus another version of Windows. If you write this into your app, that's the way it's gonna be under XP, Vista, Win7, Win98, etc (unless, of course, you write code to deal with each version of Windows, which wouldn't be too difficult).
Quite simply, when your app starts (in Sub Main or the Load event of a form, whichever you have set as your startup object), check App.PrevInstance. This will be True if the
app is already running. You can do this in a form's Load event, but Sub Main is a much better place to perform such a check (before you even load any forms).
However, there is a gotcha. App.PrevInstance only "works" if the app is started again from the same folder. So, if there happens to be 2 copies of your app's EXE file in different folders, and each of those EXEs is run, App.PrevInstance will return False when the app is run the 2nd time. It's not common to run into this situation, but it can happen.
--
Mike
.
- Follow-Ups:
- Re: Single Instance Limit
- From: xytsrm
- Re: Single Instance Limit
- From: xytsrm
- Re: Single Instance Limit
- References:
- Single Instance Limit
- From: xytsrm
- Single Instance Limit
- Prev by Date: Re: Fastest Selection
- Next by Date: Re: Drawing Guidelines
- Previous by thread: Re: Single Instance Limit
- Next by thread: Re: Single Instance Limit
- Index(es):
Relevant Pages
|