[Webinar] Streamline your web hosting managementRegister Today

x
?
Solved

Only on copy running

Posted on 1999-11-12
7
Medium Priority
?
223 Views
Last Modified: 2010-05-02
Hi!
How can I make my application so that only one copy of it at a time can be running?
If someone has a code ready for it, please send it.

Thank you!

Caminman
0
Comment
Question by:Caminman
  • 4
  • 2
7 Comments
 
LVL 1

Accepted Solution

by:
psmith789 earned 100 total points
ID: 2203581
In the startup code:

If App.PrevInstance Then Exit
0
 
LVL 32

Expert Comment

by:Erick37
ID: 2203605
In a Module, put the following code (and set your startup objest as Sub Main in Project->Properties->Startup Object):

Sub Main()
    If App.PrevInstance Then
        Exit Sub 'Exit if already running
    Else
        Form1.Show 'Else show your main form
    End If
End Sub
0
 
LVL 32

Expert Comment

by:Erick37
ID: 2203617
Microsoft article explains how to prevent multiple instances and activate the previous instance:

http://support.microsoft.com/support/kb/articles/Q185/7/30.ASP
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.

 
LVL 1

Author Comment

by:Caminman
ID: 2204013
Erick37:
Excellent answer!!
Please propose an answer, so I can give you some points
0
 
LVL 32

Expert Comment

by:Erick37
ID: 2204022
You already accepted psmith's answer :-(
0
 
LVL 1

Author Comment

by:Caminman
ID: 2204365
Yeah.... I did that didn't I... :I
Well... Isn't a "Thank you very much!!!"
Worth more than some points? :)
0
 
LVL 32

Expert Comment

by:Erick37
ID: 2204376
Yes it is. You're welcome very much.
0

Featured Post

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.

Question has a verified solution.

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

When designing a form there are several BorderStyles to choose from, all of which can be classified as either 'Fixed' or 'Sizable' and I'd guess that 'Fixed Single' or one of the other fixed types is the most popular choice. I assume it's the most p…
Since upgrading to Office 2013 or higher installing the Smart Indenter addin will fail. This article will explain how to install it so it will work regardless of the Office version installed.
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…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…
Suggested Courses
Course of the Month8 days, 17 hours left to enroll

590 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