![]() |
|
![]() |
|
|
Thread Tools | Display Modes |
|
|
|
|
#1 |
|
Professional Programmer
|
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
__________________
Forgiveness is the fragrance that the violet sheds on the heal that has crushed it. - Mark Twain Destruction leads to a very rough road, but it also breeds creation. |
|
|
|
|
|
#2 |
|
Newbie
Join Date: Mar 2006
Location: USA
Posts: 9
Rep Power: 0
![]() |
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.
|
|
|
|
|
|
#3 |
|
Programmer
|
^^hehe, thats the hard way. Try this:
Private Sub Form_Load() If (App.PrevInstance = True) Then End ![]() |
|
|
|
|
|
#4 |
|
Programmer
Join Date: Mar 2006
Location: Tennessee
Posts: 41
Rep Power: 0
![]() |
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.
|
|
|
|
|
|
#5 | |
|
Expert Programmer
|
Quote:
Use the unload function.If (App.PrevInstance = True) Then
unload Me
end if |
|
|
|
|
|
|
#6 |
|
Programmer
|
^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
![]() For Each Form In Forms
Unload Form
Next Form
End |
|
|
|
|
|
#7 |
|
Professional Programmer
|
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.
__________________
Forgiveness is the fragrance that the violet sheds on the heal that has crushed it. - Mark Twain Destruction leads to a very rough road, but it also breeds creation. |
|
|
|
![]() |
| Bookmarks |
| Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | |
| Thread Tools | |
| Display Modes | |
|
|