check if application is already opened-VBForums
Results 1 to 6 of 6

Thread: check if application is already opened

Hybrid View

  1. #1

    Thread Starter
    Frenzied Member
    Join Date
    Mar 2005
    Posts
    1,296

    check if application is already opened

    My first VB6 project!

    but my first very big prob!

    I have compiled my project with name MYPrg.exe.

    Now if a user re-click on the icon "MYPrg" the user open twice the app!!!!

    Is possible if the application MYPrg.exe is already opened, appear a Msgbox (Attention the application is alredy run on this PC)...
    How to?

  2. #2
    Addicted Member Witis's Avatar
    Join Date
    Jan 2011
    Location
    VB Forums Online Freedom Mode: Operational
    Posts
    213

    Re: check if application is already opened

    Use app.prevInstance in the startup section of your app:

    Code:
    If App.PrevInstance Then ' insert your code to exit gracefully
    All men have an inherent right to life, the right to self determination including freedom from forced or compulsory labour, a right to hold opinions and the freedom of expression, and the right to a fair trial and freedom from torture. Be aware that these rights are universal and inalienable (cannot be given, taken or otherwise transferred or removed) although you do risk losing the aforementioned rights should you fail to uphold them e.g Charles Taylor; United Nations sources: http://www.un.org/en/documents/udhr/, http://www.ohchr.org/EN/Professional...ages/CCPR.aspx. Also Charles I was beheaded on the 30th of January of 1649 for trying to replace parliamentary democracy with an absolute monarchy, the same should happen to Dr Phil and Stephen Fry; source: http://www.vbforums.com/showthread.p...ute-Monarchism.

    The plural of sun is stars you Catholic turkeys.

  3. #3

    Thread Starter
    Frenzied Member
    Join Date
    Mar 2005
    Posts
    1,296

    Re: check if application is already opened

    Quote Originally Posted by Witis View Post
    Use app.prevInstance in the startup section of your app:

    Code:
    If App.PrevInstance Then ' insert your code to exit gracefully
    ok tks...

    I use this in Form_Load event of main form:

    Code:
    If App.PrevInstance Then
            MsgBox "Application already active!", vbInformation
            Unload Me
        End If
    but when i click OK on msgbox i have this error in image:
    Attached Images Attached Images  

  4. #4
    Addicted Member Witis's Avatar
    Join Date
    Jan 2011
    Location
    VB Forums Online Freedom Mode: Operational
    Posts
    213

    Re: check if application is already opened

    That is definitely not the Application already active! msgbox you added, so you will need to step through your startup code to trace the error.

    To step through your code:
    1. Insert a stop point. Left click in the margin to the left of a line of code in your startup procedure. You will be able to see a red dot indicating a stop point is visible.
    2. Then run your application. It will stop at the break point you just created.
    3. Now step through your code a line at a time using the F8 button. Note you can use shift + F8 to skip over a call to a subroutine or a function.

    Don't forget to remove the stop point when you have finished by left clicking the red dot you created in the margin.
    All men have an inherent right to life, the right to self determination including freedom from forced or compulsory labour, a right to hold opinions and the freedom of expression, and the right to a fair trial and freedom from torture. Be aware that these rights are universal and inalienable (cannot be given, taken or otherwise transferred or removed) although you do risk losing the aforementioned rights should you fail to uphold them e.g Charles Taylor; United Nations sources: http://www.un.org/en/documents/udhr/, http://www.ohchr.org/EN/Professional...ages/CCPR.aspx. Also Charles I was beheaded on the 30th of January of 1649 for trying to replace parliamentary democracy with an absolute monarchy, the same should happen to Dr Phil and Stephen Fry; source: http://www.vbforums.com/showthread.p...ute-Monarchism.

    The plural of sun is stars you Catholic turkeys.

  5. #5

    Thread Starter
    Frenzied Member
    Join Date
    Mar 2005
    Posts
    1,296

    Re: check if application is already opened

    Quote Originally Posted by Witis View Post
    That is definitely not the Application already active! msgbox you added, so you will need to step through your startup code to trace the error.

    To step through your code:
    1. Insert a stop point. Left click in the margin to the left of a line of code in your startup procedure. You will be able to see a red dot indicating a stop point is visible.
    2. Then run your application. It will stop at the break point you just created.
    3. Now step through your code a line at a time using the F8 button. Note you can use shift + F8 to skip over a call to a subroutine or a function.

    Don't forget to remove the stop point when you have finished by left clicking the red dot you created in the margin.
    Tks! But i have resolved with:

    Code:
    Private Sub Form_Load() 
    
    If App.PrevInstance Then
    
            MsgBox "APPLICAZIONE *** " & App.Title & " *** GIA' IN ESECUZIONE!", vbInformation
    
            End
    
        End If
        
    
    End Sub

  6. #6
    Addicted Member Witis's Avatar
    Join Date
    Jan 2011
    Location
    VB Forums Online Freedom Mode: Operational
    Posts
    213

    Re: check if application is already opened

    Be careful, the End statement can sometimes cause problems, unloading is the safer way to go: http://www.a1vbcode.com/vbtip-148.asp
    All men have an inherent right to life, the right to self determination including freedom from forced or compulsory labour, a right to hold opinions and the freedom of expression, and the right to a fair trial and freedom from torture. Be aware that these rights are universal and inalienable (cannot be given, taken or otherwise transferred or removed) although you do risk losing the aforementioned rights should you fail to uphold them e.g Charles Taylor; United Nations sources: http://www.un.org/en/documents/udhr/, http://www.ohchr.org/EN/Professional...ages/CCPR.aspx. Also Charles I was beheaded on the 30th of January of 1649 for trying to replace parliamentary democracy with an absolute monarchy, the same should happen to Dr Phil and Stephen Fry; source: http://www.vbforums.com/showthread.p...ute-Monarchism.

    The plural of sun is stars you Catholic turkeys.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Featured


Click Here to Expand Forum to Full Width

Survey posted by VBForums.