By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
443,344 Members | 1,114 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 443,344 IT Pros & Developers. It's quick & easy.

Active Windows/Applications

P: n/a
I am trying to no avail, to create a program that every once in a while checks to see if another program is active. When it finds it isn't, it will make it active using the Shell command.

VB 6.0 used to have it available by calling using the Win32 but I cant find the source.

Thanks in advance.
Nov 20 '05 #1
Share this Question
Share on Google+
3 Replies


P: n/a
Try something like this code.
Public Function ProcessIsExecuting(ByVal szFile As String) As Boolean

Dim p As Process

Dim aProcName As String = Path.GetFileNameWithoutExtension(szFile)

If Process.GetProcessesByName(aProcName).Length >= 1 Then

Return True

Else

Return False

End If

End Function

Private Sub StartMyApp()

If not ProcessIsExecuting(myApp) then

Dim newProcess As New Process

newProcess.StartInfo = New
System.Diagnostics.ProcessStartInfo(myApp.Name)

newProcess.Start()

End IF

"memHog" <me****@discussions.microsoft.com> wrote in message
news:F8**********************************@microsof t.com...
I am trying to no avail, to create a program that every once in a while checks to see if another program is active. When it finds it isn't, it will
make it active using the Shell command.
VB 6.0 used to have it available by calling using the Win32 but I cant find the source.
Thanks in advance.

Nov 20 '05 #2

P: n/a
Thank you very much Steven, that will do it. I knew something had to exist but had spent about an hour looking for a solution and didn't find anything that pointed to Process object.

"Steven" wrote:
Try something like this code.
Public Function ProcessIsExecuting(ByVal szFile As String) As Boolean

Dim p As Process

Dim aProcName As String = Path.GetFileNameWithoutExtension(szFile)

If Process.GetProcessesByName(aProcName).Length >= 1 Then

Return True

Else

Return False

End If

End Function

Private Sub StartMyApp()

If not ProcessIsExecuting(myApp) then

Dim newProcess As New Process

newProcess.StartInfo = New
System.Diagnostics.ProcessStartInfo(myApp.Name)

newProcess.Start()

End IF

"memHog" <me****@discussions.microsoft.com> wrote in message
news:F8**********************************@microsof t.com...
I am trying to no avail, to create a program that every once in a while

checks to see if another program is active. When it finds it isn't, it will
make it active using the Shell command.

VB 6.0 used to have it available by calling using the Win32 but I cant

find the source.

Thanks in advance.


Nov 20 '05 #3

P: n/a
np. You might want to remove the artifact in ProcessIsExecuting.

"memHog" <me****@discussions.microsoft.com> wrote in message
news:7C**********************************@microsof t.com...
Thank you very much Steven, that will do it. I knew something had to exist but had spent about an hour looking for a solution and didn't find
anything that pointed to Process object.
"Steven" wrote:
Try something like this code.
Public Function ProcessIsExecuting(ByVal szFile As String) As Boolean

Dim p As Process

Dim aProcName As String = Path.GetFileNameWithoutExtension(szFile)

If Process.GetProcessesByName(aProcName).Length >= 1 Then

Return True

Else

Return False

End If

End Function

Private Sub StartMyApp()

If not ProcessIsExecuting(myApp) then

Dim newProcess As New Process

newProcess.StartInfo = New
System.Diagnostics.ProcessStartInfo(myApp.Name)

newProcess.Start()

End IF

"memHog" <me****@discussions.microsoft.com> wrote in message
news:F8**********************************@microsof t.com...
I am trying to no avail, to create a program that every once in a
while checks to see if another program is active. When it finds it isn't, it will make it active using the Shell command.

VB 6.0 used to have it available by calling using the Win32 but I cant

find the source.

Thanks in advance.


Nov 20 '05 #4

This discussion thread is closed

Replies have been disabled for this discussion.