|
-
May 21st, 1999, 07:34 AM
#1
kernel32 lib problems
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
-
May 24th, 1999, 05:24 AM
#2
Re: kernel32 lib problems
Hi,
I would guess 'Secuirity' problems!. NT is more stringent than '95.
You have not mentioned as to how your are starting the other process (DOS program). Check out ShellExecute (API)instead of just Shell (VB).
Also what you are trying to do can be accomplished by WaitforSingleObject API. and the process goes into a 'signaled' state when it terminates. This call is performance-tuned too.
Ravi
-
May 25th, 1999, 02:46 AM
#3
Re: kernel32 lib problems
I was using shell. I'll try shellexecute.
By the way, where can I find some information about the API declarations?
Thanks,
Rik
-
May 25th, 1999, 10:26 AM
#4
Re: kernel32 lib problems
Searching for the waitforsingleobject function,is the msdn library I found a solution. (Tip 173: http://msdn.microsoft.com/library/te...dn_msdn173.htm).
Thanks for the tip on the waitforsingleobject function.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|