![]() |
Program Open Already?
Hey yall. I am wantign to make a program that when it is terminated it reopens it self. I alreayd got that part but I also need it if it is opend once laready not to open it again, Right now it opens 280 times and then the computer freezes. lol. So please help me. Also is it possible to make a program run as a service? If so how?
Thanks again yall |
What you can do is write a variable to a file when you open the program. Then check that file to see if the program is running. Example: when you're program starts write the number 1 to C:\isrunning.txt. Then whenever you try to start the program first check if the number 1 is in C:\isrunning.txt. Also don't forget to change the number to 0 or something else not 1 before you close your program.
|
^^hehe, thats the hard way. Try this:
:
Private Sub Form_Load() |
wouldn't that have a lot of overhead though, always trying to start the program then shutting itself down? seems you could put something in the program exit call to start another instance of itself, that way it will only restart itself when it shuts itself down.
|
Quote:
:
If (App.PrevInstance = True) Then |
^well if you really want to be thorough you can go though and Unload every form using a for loop.. though I always add an End at the end of it just in case :D
:
For Each Form In Forms |
Well see its a progra, that blocks stuff. And I dont want people to use ctrl - alt - del to close it through procesess. So I put it in Form_Terminate to when it closes like that it starts up. But I got it to start up 2 78 times once. So this is why I need this.
|
| All times are GMT -5. The time now is 5:10 AM. |
Powered by vBulletin® Version 3.7.0, Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Copyright ©2007 DaniWeb® LLC