Detecting a running process.



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


.



Relevant Pages


Loading