|
-
Aug 6th, 2007, 09:23 AM
#1
Thread Starter
Registered User
[RESOLVED] [2005] Show an already running process
Howdy all,
Here's an example of what I'm trying to do. If my process has not started, then start it. If my process has started, then bring the currently running process to the front instead of opening another instance of it. For example
vb.net Code:
Private p As Process = Nothing
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
If p Is Nothing OrElse p.HasExited Then
p = New Process()
p.StartInfo.FileName = "c:\test.txt"
p.Start()
Else
' This process is already running so
' bring is to the front/maximize it
' instead of opening another one.
End If
End Sub
I've waded through the Process class but have not found what I'm looking for. How can I, if in the example above, I already have an instance of NotePad open, bring it to the front instead of opening another instance?
Am I smelling API of some sort? Sorry if this turns out to be the inappropriate forum. Thanks.
-
Aug 6th, 2007, 09:50 AM
#2
Re: [2005] Show an already running process
No API needed...
Code:
Private p As Process = Nothing
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
If p Is Nothing OrElse p.HasExited Then
p = New Process()
p.StartInfo.FileName = "c:\test.txt"
p.Start()
Else
' This process is already running so
' bring is to the front/maximize it
' instead of opening another one.
AppActivate(p.Id)
End If
End Sub
-
Aug 6th, 2007, 09:52 AM
#3
Thread Starter
Registered User
Re: [2005] Show an already running process
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|