CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 3 of 3
  1. #1
    Join Date
    Apr 1999
    Posts
    57

    URGENT : Avoiding multiple VB instances ??



    How do I prevent running of multiple VB instances ?


    Anand

  2. #2
    Join Date
    May 1999
    Location
    Oxford UK
    Posts
    1,459

    Re: URGENT : Avoiding multiple VB instances ??



    Hi


    Do you mean - multiple instances of your VB application, or multiple instances of Visual Basic itself ?


    The first one is quite easy, the global App object in VB has a 'PrevInstance' property which lets you know if a previous instance of your application is running, eg.


    Sub Main()

    If App.PrevInstance Then

    '

    ' Do nothing - or quit, whatever

    '

    Else

    '

    ' Load the applications main form

    '

    Load mFrmMain

    mFrmMain.Show

    End If

    End Sub


    The second one would require a small vb app to be constantly running in the background, looking at all the top level windows running on the system. This way, you could kill off another instance of VB if it was running (it's a hack, but I don't know of any other way). I saw some code a while back which was designed to stop people running specified programs on their machines (eg. Solitaire, WinMine etc), I'll try and find it if you want.


    Regards


    Chris Eastwood

    Codeguru - the website for developers

    http://www.codeguru.com/vb



  3. #3
    Join Date
    Apr 1999
    Posts
    57

    Re: URGENT : Avoiding multiple VB instances ??



    Hi Chris


    I was looking for the first one. Thanks a lot


    Anand

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

Featured