|
|
Title | Make sure only one instance of a program can run at one time on a computer |
Description | This example shows how to make sure only one instance of a program can run at one time on a computer in Visual Basic 6. When the program starts, it checks App.PrevInstance to see if an instance of the program is already running and exits if one is. |
Keywords | one instance, instance, DDE |
Categories | Software Engineering, Windows |
|
|
When the program starts, it checks App.PrevInstance to see if an instance of the program is already running. If one is, the program says so, uses AppActivate to activate that instance, and exits.
|
|
Private Sub Form_Load()
Dim cap As String
If App.PrevInstance Then
' Tell the user that another instance is already
' running.
MsgBox "Another instance of the program is already " & _
"running", vbCritical
' Activate the other instance.
cap = Me.Caption
Me.Caption = ""
AppActivate cap
' Exit.
Unload Me
End If
End Sub
|
|
|
|
|
|