Check if any app is running in VB .NET

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I'm looking for a VB code that would run on a device to check if "any"
application is running on the device. I only found C code that does
that...Thank you!
 
You can use the ProcessEntry class in OpenNETCF.Toolhelp will do that.
There are *always* processes running. There are *no* cases where no
processes can be running on a working device.

Paul T.
 
By "any" I meant a specific application.
So, I have to get all the processes running and then loop through them to
see if any of them is my application to determine if it's running...Is there
a way to "directly" check if this specific process is running?
 
If it's your app and you have code control,. then grab a named mutex at app
startup. Then you can always see if anything has the mutex from any other
app. If it's held, the app is running. Obviously the app needs to release
it on close as well.

--
Chris Tacke
Co-founder
OpenNETCF.org
Has OpenNETCF helped you? Consider donating to support us!
http://www.opennetcf.org/donate
 
You'd have to know the name of the EXE, which is what is returned when
toolhelp returns the process information. Yes, you'd have to examine
potentially all of the running processes for the one you're interested in.
No, not unless you know something else about the process (the name of its
window class, etc.)

Paul T.
 
Where can I find some sample code?

Paul G. Tobey said:
You'd have to know the name of the EXE, which is what is returned when
toolhelp returns the process information. Yes, you'd have to examine
potentially all of the running processes for the one you're interested in.
No, not unless you know something else about the process (the name of its
window class, etc.)

Paul T.
 
I found some code on the Internet:
OpenNetCF.ToolHelp.ProcessEntry.GetProcesses()
but I think that for OpenNetCF I need toolhelp32.dll - where can I get it?
I've got Windows XP and it's not in my system.
 
It runs on the device, not on your PC. toolhelp.dll is on all Pocket PC's.
If you're using a vanilla CE device, check the \Windows folder or check with
the OEM to see if it's there (or just try running the code, it'll either
work or not).

--
Chris Tacke
Co-founder
OpenNETCF.org
Has OpenNETCF helped you? Consider donating to support us!
http://www.opennetcf.org/donate
 
Thanks a lot for your help! I was able to get it running. This is my function:

Public Shared Function IsAppRunning(ByVal appName) As Boolean

Dim myProcesses() As ProcessEntry
Dim instance As ProcessEntry
myProcesses = ProcessEntry.GetProcesses()

For Each instance In myProcesses
If instance.ExeFile.Trim = appName Then
Return False
End If
Next
Return True
End Function

I don't see anything similar to GetProcessesByName so do I really have to
loop through all the processes? Paul G. Tobey (post on 4/19/05) said:
"No, not unless you know something else about the process (the name of its
window class, etc.)"
but how to do this?
 
Back
Top