Detecting a previous instance of your application
By: Lorenzo Dalla Vecchia Date: 13/07/1998
File:

anotherinstance.zip

Size:

430 bytes

Download now!

This routine will prevent two copies of your program from running at the same time. It consists of a function that determines if another instance is already running and activates it if it is. The Sub Form_Load calls this function and closes the program if there is another instance of the program running.

Syntax

AnotherInstance()

Parameters

N/A

Type of data

Boolean

Returns

True if another instance is running
False if not

-

In the Form_Load event, put this line at the beginning:

If AnotherInstance() Then End

Note that this function will not work if the application's title changes (i.e. showing filenames in the title bar).

The function is contained in a module. You can cut and paste it in any program of yours.

Click Here!


Visual Basic Programming Zone is a website by Lorenzo Dalla Vecchia.
To contact the Webmaster, click here.
Hosted by InWind: www.inwind.it