Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. Visual Basic
  4. Run only Single Instance of exe

Run only Single Instance of exe

Scheduled Pinned Locked Moved Visual Basic
tutorialhelpquestion
9 Posts 4 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • A Offline
    A Offline
    Atul Kharecha
    wrote on last edited by
    #1

    Hi all, Can you please let me know how to create .exe file in vb6, there can be only single instance is running at a time? For example if i double click on exe file, it start running. I minimize that exe and again double click on same exe file, it should display me message that program is already running. Can anyone help? Thanks. Atul -- modified at 1:33 Wednesday 23rd November, 2005

    B J 2 Replies Last reply
    0
    • A Atul Kharecha

      Hi all, Can you please let me know how to create .exe file in vb6, there can be only single instance is running at a time? For example if i double click on exe file, it start running. I minimize that exe and again double click on same exe file, it should display me message that program is already running. Can anyone help? Thanks. Atul -- modified at 1:33 Wednesday 23rd November, 2005

      B Offline
      B Offline
      Briga
      wrote on last edited by
      #2

      For me one of the best code to answer your question is the following but you need to rewrite it in VB6 (you'll learn something in the meantime): http://www.codeproject.com/threads/singleinstance.asp Otherwise you can look here a find it already done, how to create a mutex in VB6: http://www.vbaccelerator.com/home/VB/Code/Libraries/Shell\_Projects/Registering\_File\_Associations/VB6\_Startup\_Demonstration\_zip\_mMain\_bas.asp If you'll move to FW 1.x then it's much easier: http://www.codeproject.com/vb/net/ActivateSingleAppInstance.asp And with VS2005 and FW 2.x then even more beacuse you just need to tick a box!

      A S 2 Replies Last reply
      0
      • A Atul Kharecha

        Hi all, Can you please let me know how to create .exe file in vb6, there can be only single instance is running at a time? For example if i double click on exe file, it start running. I minimize that exe and again double click on same exe file, it should display me message that program is already running. Can anyone help? Thanks. Atul -- modified at 1:33 Wednesday 23rd November, 2005

        J Offline
        J Offline
        jonathan15
        wrote on last edited by
        #3

        In vb6 this couldnt be any easier. There is an app object which has a property called PrevInstance. In the form load event of your startup form simply check it as follows: If app.previnstance then msgbox "I really Should google for simple stuff like this" 'To do it properly you should put code here to set focus to the 'existing instance else ' code to either do something or leave blank to continue end if Jon

        A 1 Reply Last reply
        0
        • B Briga

          For me one of the best code to answer your question is the following but you need to rewrite it in VB6 (you'll learn something in the meantime): http://www.codeproject.com/threads/singleinstance.asp Otherwise you can look here a find it already done, how to create a mutex in VB6: http://www.vbaccelerator.com/home/VB/Code/Libraries/Shell\_Projects/Registering\_File\_Associations/VB6\_Startup\_Demonstration\_zip\_mMain\_bas.asp If you'll move to FW 1.x then it's much easier: http://www.codeproject.com/vb/net/ActivateSingleAppInstance.asp And with VS2005 and FW 2.x then even more beacuse you just need to tick a box!

          A Offline
          A Offline
          Atul Kharecha
          wrote on last edited by
          #4

          Hi Briga, Thanks a lot for your suggestion. Atul

          1 Reply Last reply
          0
          • J jonathan15

            In vb6 this couldnt be any easier. There is an app object which has a property called PrevInstance. In the form load event of your startup form simply check it as follows: If app.previnstance then msgbox "I really Should google for simple stuff like this" 'To do it properly you should put code here to set focus to the 'existing instance else ' code to either do something or leave blank to continue end if Jon

            A Offline
            A Offline
            Atul Kharecha
            wrote on last edited by
            #5

            Hi Jon, Thank you very much for your valuable suggestion. Atul.

            B 1 Reply Last reply
            0
            • B Briga

              For me one of the best code to answer your question is the following but you need to rewrite it in VB6 (you'll learn something in the meantime): http://www.codeproject.com/threads/singleinstance.asp Otherwise you can look here a find it already done, how to create a mutex in VB6: http://www.vbaccelerator.com/home/VB/Code/Libraries/Shell\_Projects/Registering\_File\_Associations/VB6\_Startup\_Demonstration\_zip\_mMain\_bas.asp If you'll move to FW 1.x then it's much easier: http://www.codeproject.com/vb/net/ActivateSingleAppInstance.asp And with VS2005 and FW 2.x then even more beacuse you just need to tick a box!

              S Offline
              S Offline
              samperiau
              wrote on last edited by
              #6

              >And with VS2005 and FW 2.x then even more beacuse you just need to tick a box! Where? :-)

              B 1 Reply Last reply
              0
              • S samperiau

                >And with VS2005 and FW 2.x then even more beacuse you just need to tick a box! Where? :-)

                B Offline
                B Offline
                Briga
                wrote on last edited by
                #7

                Go under the Project Properties, then Application tab. Enable the Application Framework and one of the options is: Make Single Instance Application. Tick the box.

                S 1 Reply Last reply
                0
                • A Atul Kharecha

                  Hi Jon, Thank you very much for your valuable suggestion. Atul.

                  B Offline
                  B Offline
                  Briga
                  wrote on last edited by
                  #8

                  Yes, although I don't know why, but lot of programmes consider that object unreliable and that's the reason why some of them use a mutex and also a market has opened up (i.e. the activex oneonly, but there are more around).

                  1 Reply Last reply
                  0
                  • B Briga

                    Go under the Project Properties, then Application tab. Enable the Application Framework and one of the options is: Make Single Instance Application. Tick the box.

                    S Offline
                    S Offline
                    samperiau
                    wrote on last edited by
                    #9

                    It has been staring me in the face for hours!!:sigh: X| It seems to work well. If I try to run the program again there is a short delay and then the first instance comes bak in foucus.

                    1 Reply Last reply
                    0
                    Reply
                    • Reply as topic
                    Log in to reply
                    • Oldest to Newest
                    • Newest to Oldest
                    • Most Votes


                    • Login

                    • Don't have an account? Register

                    • Login or register to search.
                    • First post
                      Last post
                    0
                    • Categories
                    • Recent
                    • Tags
                    • Popular
                    • World
                    • Users
                    • Groups