I've created a program with vb2010 and I am kinda stuck with the following:
When I run the program it checks if there is an update for it, if so, then the exe is downloaded and is executed, the program (main program) then checks if the setup is running, if so the program quits so the setup can continue.
But at this point, everything works fine, until the point that the setup is executed, the program keeps running (the splashscreen starts), while it should stop.
Here is the code I use:
At start (if the setup is running) the message of setup is running is shown. But the program continues to start.
Any suggestions are welcome.
When I run the program it checks if there is an update for it, if so, then the exe is downloaded and is executed, the program (main program) then checks if the setup is running, if so the program quits so the setup can continue.
But at this point, everything works fine, until the point that the setup is executed, the program keeps running (the splashscreen starts), while it should stop.
Here is the code I use:
VB.NET:
Public Shared Function isprocessrunning(ByVal name As String) As Boolean
For Each proc As Process In Process.GetProcesses
If proc.ProcessName.StartsWith(name) Then
Return True
End If
Next
Return False
End Function
Public Shared Sub KillApp(ByRef strProcessToKill As String)
Dim proc() As Process = Process.GetProcesses
For i As Integer = 0 To proc.GetUpperBound(0)
If proc(i).ProcessName = strProcessToKill Then
proc(i).Kill()
End If
Next
End Sub
Private Sub SplashScreen1_Load(sender As Object, e As System.EventArgs) Handles Me.Load
If isprocessrunning("Songlist Editor 2 setup") Then
Dim button As DialogResult
button = MessageBox.Show _
("Setup is running, please close application!", _
"Songlist Editor 2", MessageBoxButtons.OK, MessageBoxIcon.Exclamation, MessageBoxDefaultButton.Button1)
If button = Windows.Forms.DialogResult.OK Then
'MessageBox.Show("setup is running, please close application!")
KillApp("Songlist Editor 2")
End If
End If
End Sub
Any suggestions are welcome.