May 21st, 1999, 07:34 AM
Hi,
In a program I wrote, I used following function that calls the kernel32 lib
to check if a proces (a Dos program that writes a ascci-file) has terminated
(see below).
It works fine under Windows 95 but with NT4.0 id doesn't work.
What could be the problem.
Please help me,
Rik
Declare Function CloseHandle Lib "kernel32" (byval hObject as Long) as Long
Declare Function OpenProcess Lib "kernel32" (byval dwDesiredAccess as Long,
byval bInheritHandle as Long, byval dwProcessID as Long) as Long
Declare Function GetExitCodeProcess Lib "kernel32" (byval hProcess as Long,
lpExitCode as Long) as Long
public Function TestIfProcessStillAlive(ProcessID as Long) as Boolean
Dim Alive_ones as Long
Dim LoopTroughProcess as Long
Dim AlivePulse as Long
Dim hProcess as Long
Dim lngExitCode as Long
AlivePulse = 0
If ProcessID <> 0 then
hProcess = OpenProcess(PROCESS_QUERY_INFORMATION, false, ProcessID)
If hProcess <> 0 then
GetExitCodeProcess hProcess, lngExitCode
else 'process not found
TestIfProcessStillAlive = false
Exit Function
End If
'if you open a handle then you have to close it too
CloseHandle (hProcess)
else
TestIfProcessStillAlive = false
Exit Function
End If
If lngExitCode = 259 then
TestIfProcessStillAlive = true
else
If lngExitCode = 0 then TestIfProcessStillAlive = false
End If
End Function
In a program I wrote, I used following function that calls the kernel32 lib
to check if a proces (a Dos program that writes a ascci-file) has terminated
(see below).
It works fine under Windows 95 but with NT4.0 id doesn't work.
What could be the problem.
Please help me,
Rik
Declare Function CloseHandle Lib "kernel32" (byval hObject as Long) as Long
Declare Function OpenProcess Lib "kernel32" (byval dwDesiredAccess as Long,
byval bInheritHandle as Long, byval dwProcessID as Long) as Long
Declare Function GetExitCodeProcess Lib "kernel32" (byval hProcess as Long,
lpExitCode as Long) as Long
public Function TestIfProcessStillAlive(ProcessID as Long) as Boolean
Dim Alive_ones as Long
Dim LoopTroughProcess as Long
Dim AlivePulse as Long
Dim hProcess as Long
Dim lngExitCode as Long
AlivePulse = 0
If ProcessID <> 0 then
hProcess = OpenProcess(PROCESS_QUERY_INFORMATION, false, ProcessID)
If hProcess <> 0 then
GetExitCodeProcess hProcess, lngExitCode
else 'process not found
TestIfProcessStillAlive = false
Exit Function
End If
'if you open a handle then you have to close it too
CloseHandle (hProcess)
else
TestIfProcessStillAlive = false
Exit Function
End If
If lngExitCode = 259 then
TestIfProcessStillAlive = true
else
If lngExitCode = 0 then TestIfProcessStillAlive = false
End If
End Function