Re: Single Instance Limit





"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



.



Relevant Pages

  • Re: Single Instance Limit
    ... I have a second question if three instances of an APP runs and the first to ... It's a matter of writing code to handle it. ... You can do this in a form's Load event, ... your app's EXE file in different folders, and each of those EXEs is run, ...
    (microsoft.public.vb.general.discussion)
  • RE: SHA-based subclass for random module
    ... Yes, but different RNGs have different weaknesses, and whether the ... If you need to generate "random" points in 3D space, does it matter that the ... if your app relies on the triples ... distribution in 3D space. ...
    (comp.lang.python)
  • Re: Tkinter or wxpython?
    ... mean by a "good reason" to write a desktop gui. ... Might or might not matter depending on the application. ... Compared to a desktop app? ...
    (comp.lang.python)
  • Re: newbie: self.member syntax seems /really/ annoying
    ... It's a matter of taste, so there is no point in bashing a valid ... It's not just a matter of taste. ... they can use any conventions they feel like. ... But if you're writing code that is going to be seen by others in the ...
    (comp.lang.python)
  • Re: cmd.exe and rexx
    ... The number of executions doesn't matter, as long as it's at least one. ... The app doesn't have to store the data in a variable, ...  >> Porting a stable version of ooRexx like 3.2.x is a better bet ...
    (comp.os.os2.apps)