Prevent multiple copies running

Is there a way to prevent the user from starting more than one copy of my program?  It's an "In-House" app, and night shift likes to start enough instances to run out of memory and take a break.
WSRAsked:
Who is Participating?
 
KDivadConnect With a Mentor Commented:
First line of code in your app:

If App.PrevInstance Then End
0
 
mcriderCommented:
HOWTO: Prevent Multiple Instances of a 32-bit VB Application
0
 
mcriderCommented:
Missed pasting URL, Here it is...


HOWTO: Prevent Multiple Instances of a 32-bit VB Application
http://support.microsoft.com/support/kb/articles/Q185/7/30.ASP

 
 Cheers!
0
Never miss a deadline with monday.com

The revolutionary project management tool is here!   Plan visually with a single glance and make sure your projects get done.

 
caraf_gCommented:
KDivad's suggestion is the correct one and it was mentioned first, so KDivad should get the points.
0
 
mcriderCommented:
caraf_g,

From: KDivad
 Date: Friday, October 29 1999 - 08:27AM EDT  
From: mcrider
 Date: Friday, October 29 1999 - 08:27AM EDT

Notice anything?
0
 
JuiletteCommented:
Shark Attack! These points make people crazy. Here's the code....maybe you should flip a coin between the two seeing as they have same times posted...
Really....

' See if there is already and instance.
    If App.PrevInstance Then
        ' Activate the previous instance
        AppActivate App.Title
       
        ' Send a key (here SHIFT-key) to set the
        ' form from the previous instance to the
        ' top of the screen.
        SendKeys "+", True
       
        ' Terminate the new instance
        Unload Me
    End If


0
 
KDivadCommented:
Give the points to mcrider. He/She DID post first, even though the link was missing and I couldn't care any less about the points.
0
 
WSRAuthor Commented:
First answer was my question.  Second answer, as a comment, was posted after KDivad's comment.  I tried KDivad's solution and it worked.  Microsoft's code was more complete, but for in-house use, KISS is better.  Thanks everybody!
0
 
KDivadCommented:
You're Welcome!
Thanks!
0
All Courses

From novice to tech pro — start learning today.