Detecting a running process.
- From: "Steve Easton" <admin@xxxxxxxxxxxxx>
- Date: Mon, 2 May 2005 17:45:52 -0400
I found a script to detect running process here:
http://vbnet.mvps.org/index.html?code/system/toolhelpprocesses.htm
However, I modified it to scan the processes and set a string variable to 1 if one certain process
is running as follows:
Dim hSnapShot As Long
Dim isrun As String
Dim uProcess As PROCESSENTRY32
Dim success As Long
Const frontp As String = "FRONTPG.EXE"
hSnapShot = CreateToolhelp32Snapshot(TH32CS_SNAPPROCESS, 0&)
If hSnapShot = -1 Then Exit Sub
uProcess.dwSize = Len(uProcess)
success = ProcessFirst(hSnapShot, uProcess)
If success = 1 Then
isrun = 0
Do
If Left$(uProcess.szExeFile, 11) = frontp Then isrun = isrun + 1
Loop While ProcessNext(hSnapShot, uProcess)
End If
Call CloseHandle(hSnapShot)
At this point if FRONTPG.EXE is running the value isrun = 1
and I use it to open a message box alerting the user to close FrontPage before continuing.
Problem is, it won't work in windows NT because CreateToolhelp32Snapshot isn't available on NT
So, my questions are, Is there a better way to do this and is there a way that's compatible with NT.
tyia
--
Steve Easton
Microsoft MVP FrontPage
95isalive
This site is best viewed............
........................with a computer
.
- Follow-Ups:
- Re: Detecting a running process.
- From: Harry Bates
- Re: Detecting a running process.
- From: Sam Hobbs
- Re: Detecting a running process.
- From: Casey Provance
- Re: Detecting a running process.
- From: Randy Birch
- Re: Detecting a running process.
- From: Casey Provance
- Re: Detecting a running process.
- From: Tom Esh
- Re: Detecting a running process.
- Prev by Date: Re: VB 6 install / run on Win x86-64 OK?
- Next by Date: Re: Determining Win XP vs. Classic styles
- Previous by thread: Create a service from vb.net
- Next by thread: Re: Detecting a running process.
- Index(es):
Relevant Pages
|
Loading