Results 1 to 6 of 6

Thread: App Previous Instance with Windows NT

  1. #1

    Thread Starter
    New Member
    Join Date
    Mar 2000
    Location
    Greenville, NC, USA
    Posts
    15
    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.

  2. #2
    I'm about to be a PowerPoster! Joacim Andersson's Avatar
    Join Date
    Jan 1999
    Location
    Sweden
    Posts
    14,649
    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!

  3. #3
    New Member
    Join Date
    Aug 2001
    Location
    Columbia, SC
    Posts
    1
    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

  4. #4
    Member tsoftonline's Avatar
    Join Date
    Aug 2001
    Posts
    42
    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.

  5. #5

  6. #6
    Fanatic Member
    Join Date
    Aug 2000
    Posts
    879
    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
  •  



Click Here to Expand Forum to Full Width