Programming Forums
User Name Password Register
 

RSS Feed
FORUM INDEX | TODAY'S POSTS | UNANSWERED THREADS | ADVANCED SEARCH

Reply
 
Thread Tools Display Modes
Old Mar 30th, 2006, 9:39 PM   #1
bigguy
Professional Programmer
 
bigguy's Avatar
 
Join Date: Sep 2005
Location: Arkansas
Posts: 298
Rep Power: 0 bigguy is an unknown quantity at this point
Send a message via AIM to bigguy Send a message via MSN to bigguy Send a message via Yahoo to bigguy
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.
bigguy is offline   Reply With Quote
Old Mar 30th, 2006, 10:47 PM   #2
jeffball55
Newbie
 
Join Date: Mar 2006
Location: USA
Posts: 9
Rep Power: 0 jeffball55 is on a distinguished road
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.
jeffball55 is offline   Reply With Quote
Old Mar 31st, 2006, 12:56 AM   #3
brownhead
Programmer
 
Join Date: Mar 2006
Location: California
Posts: 37
Rep Power: 0 brownhead is on a distinguished road
Send a message via AIM to brownhead Send a message via MSN to brownhead
^^hehe, thats the hard way. Try this:
Private Sub Form_Load()
If (App.PrevInstance = True) Then End
App.PrevInstance = True if there is already an instance of your program running.. so this should do the trick
brownhead is offline   Reply With Quote
Old Mar 31st, 2006, 1:31 AM   #4
PPoA
Programmer
 
PPoA's Avatar
 
Join Date: Mar 2006
Location: Tennessee
Posts: 41
Rep Power: 0 PPoA is on a distinguished road
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.
PPoA is offline   Reply With Quote
Old Mar 31st, 2006, 1:33 AM   #5
Booooze
Expert Programmer
 
Booooze's Avatar
 
Join Date: Mar 2006
Location: Igloo
Posts: 710
Rep Power: 3 Booooze is on a distinguished road
Send a message via MSN to Booooze
Quote:
If (App.PrevInstance = True) Then End
Don't use end. It doesn't clear up everything in memory properly Use the unload function.

If (App.PrevInstance = True) Then 
     unload Me
end if
Booooze is offline   Reply With Quote
Old Mar 31st, 2006, 2:30 AM   #6
brownhead
Programmer
 
Join Date: Mar 2006
Location: California
Posts: 37
Rep Power: 0 brownhead is on a distinguished road
Send a message via AIM to brownhead Send a message via MSN to brownhead
^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
brownhead is offline   Reply With Quote
Old Mar 31st, 2006, 1:12 PM   #7
bigguy
Professional Programmer
 
bigguy's Avatar
 
Join Date: Sep 2005
Location: Arkansas
Posts: 298
Rep Power: 0 bigguy is an unknown quantity at this point
Send a message via AIM to bigguy Send a message via MSN to bigguy Send a message via Yahoo to bigguy
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.
bigguy is offline   Reply With Quote
Reply

Bookmarks

« Previous Thread in Forum | Next Thread in Forum »

Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump




DaniWeb IT Discussion Community
All times are GMT -5. The time now is 12:17 AM.

Powered by vBulletin® Version 3.7.0, Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Copyright ©2007 DaniWeb® LLC