Run only Single Instance of exe
-
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
-
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
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!
-
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
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
-
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!
Hi Briga, Thanks a lot for your suggestion. Atul
-
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
Hi Jon, Thank you very much for your valuable suggestion. Atul.
-
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!
-
>And with VS2005 and FW 2.x then even more beacuse you just need to tick a box! Where? :-)
-
Hi Jon, Thank you very much for your valuable suggestion. Atul.
-
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.