U can create a txt file to check this:
Every 3 minutes - Timer-60000*3 - the main program “cserver.exe” will write the current time in a file:
Code:WriteAlive() Open App.Path & "\Live.txt" For Output As #1 Print #1, Time$ Close #1Code:Private Sub Load () - main program cserver.exe load If App.PrevInstance = True Then Unload Me Exit Sub End If Shell App.Path & "\Monitor.exe " End SubEvery 1 minutes - Timer-60000*1- the Monitor program “Monitor.exe” will check the same file and if necessary, kill & Reopen cserver.exe:Code:Private Sub Unload() - main program cserver.exe unload Open App.Path & "\Log.txt" For Output As #1 Print #1, "User Closed" & Time$ Close #1 KillProcess "Monitor.exe" 'No need to Monitor End Sub
Code:CheckAlive() Dim TextLine, X Open App.Path & "\Live.txt" For Input As #1 Line Input #1, TextLine Close #1 X = DateDiff("n", TextLine, Time$) If X > 3 Then KillProcess "cserver.exe" 'Kill Open App.Path & "\Log.txt" For Output As #1 Print #1, "Stopped responding, Killed and re-opened" & Time$ Close #1 Shell App.Path & "\cserver.exe" 'Re-Open End IfCheck this:Code:Private Sub Load () - Monitor program Monitor.exe load If App.PrevInstance = True Then Unload Me Exit Sub End If End Sub
http://www.vbforums.com/showthread.php?t=651961




Reply With Quote