Solved

Preventing multiple instances of a VB EXE from running?

Posted on 2001-06-13
4
246 Views
Last Modified: 2012-05-04
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?
0
Comment
Question by:david749
  • 3
4 Comments
 
LVL 4

Accepted Solution

by:
beckingh earned 50 total points
ID: 6185837
If App.PrevInstance = True Then
        MsgBox "There are two instances of the application running.  Please click OK, wait 10 seconds, and restart the application.  If the problem persists contact your System Administrator.", vbOKOnly, csMsgBoxTitle
        GoTo exitsub
    End If
0
 
LVL 4

Expert Comment

by:beckingh
ID: 6185844
Obviously only the "If App.PrevInstance = True Then" part is relevant :)
0
 
LVL 4

Expert Comment

by:beckingh
ID: 6185858
Here's a nice link to a way of launching the app that is already running.

http://vbcode.com/asp/showsn.asp?theID=574
0
 
LVL 16

Expert Comment

by:Richie_Simonetti
ID: 6187559
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.
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

I was working on a PowerPoint add-in the other day and a client asked me "can you implement a feature which processes a chart when it's pasted into a slide from another deck?". It got me wondering how to hook into built-in ribbon events in Office.
You can of course define an array to hold data that is of a particular type like an array of Strings to hold customer names or an array of Doubles to hold customer sales, but what do you do if you want to coordinate that data? This article describes…
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…

863 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

20 Experts available now in Live!

Get 1:1 Help Now