|
-
Mar 15th, 2000, 08:10 PM
#1
Thread Starter
New Member
I have not been able to find any code to look for a previous instance of an application using Windows NT. Does any one know how to code this and it actually work.
-
Mar 15th, 2000, 09:12 PM
#2
I don't know if I understand you correctly but if you want to check for a previous instance of your app use the following code in the Load event of your main form.
Code:
Private Sub Form_Load()
If App.PrevInstance = True Then
'a previous instance of this
'application is running
End If
End Sub
This works on both Win9x and WinNT.
Good luck!
-
Aug 15th, 2001, 02:37 PM
#3
New Member
You can try this and see what happens.
If App.PrevInstance = True Then
MsgBox "There is already one instance of this program running. You cannot run more than one version at a time.", vbCritical + vbOKOnly, m_sERROR
Call StopApplication
End
End If
Public Sub StopApplication()
'-- <Purpose>
' Stops all forms and ends program
'
' Parameters:
' <None>
'
' Returns:
' <None>
'-- Local variables declared
Dim frm As Form
' Loop thru the forms collection and
' unload all forms from memory
For Each frm In Forms
frm.Hide ' hide the form
Unload frm ' deactivate the form
Set frm = Nothing ' remove from memory
Next
End Sub
-
Aug 15th, 2001, 02:39 PM
#4
Member
Yeah, App.PrevInstance should work on NT.
Executive Project Director
Technosoft Enterprises
Any of my opinions stated on this or any other forums do not represent the official policy of Technosoft Enteprises, unless otherwise specified.
-
Aug 15th, 2001, 02:41 PM
#5
PowerPoster
-
Aug 15th, 2001, 02:41 PM
#6
Fanatic Member
LOL..it would work BUT...if you change the EXE name and double click it again, it will run. HEHE. I suggest you use a work around of some sort. Maybe put a string in a file or the registry and check if it's there when you load the app?/
Visual Basic 6.0
Visual C++ 5
Delphi 5

Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|