Link to home
Start Free TrialLog in
Avatar of david749
david749

asked on

Preventing multiple instances of a VB EXE from running?

I have a VB app that is delivered in the form of an EXE file.  I must prevent the user from running multiple instances of this program.  How do I do this?
ASKER CERTIFIED SOLUTION
Avatar of beckingh
beckingh

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of beckingh
beckingh

Obviously only the "If App.PrevInstance = True Then" part is relevant :)
Here's a nice link to a way of launching the app that is already running.

http://vbcode.com/asp/showsn.asp?theID=574
Avatar of Richie_Simonetti
One way to do it is adding a module to your project, create a sub Main procedure and:

Sub Main
    If app.previnstance then
       end
    else
       frmMain.show
    end if
End Sub

Don't forget to swith your start object to the sub main routine going to Project properties menu.