for creating single instance application study mutax
On Tue, Apr 7, 2009 at 3:05 PM, Benj Nunez <[email protected]> wrote: > > Code it this way: > > > Public Sub killProcess(ByVal strProcessToKill As String) > > Dim pProcess() As Process = > System.Diagnostics.Process.GetProcessesByName(strProcessToKill) > > For Each p As Process In pProcess > p.Kill() > Next > > End Sub > > > > > > On Mar 3, 12:17 am, Tom C <[email protected]> wrote: > > I have a single instance application that will not close with the > > following code. It just ignores the close command. Anyone have any > > ideas why or what I can do to force the application to close? > > > > testInstances = System.Diagnostics.Process.GetProcessesByName > > (processName) > > For z As Integer = 1 To 5 > > If testInstances.Length > 0I Then > > For i As Integer = testInstances.Length - 1I > > To 0I Step -1 > > Dim instance As System.Diagnostics.Process > > = testInstances(i) > > instance.WaitForExit(1000) > > instance.Close() > > Next > > testInstances = > > System.Diagnostics.Process.GetProcessesByName(processName) > > Else > > Exit For > > End If > > Next -- Muhammad Arif Software Engineer +923009347315
