Raseni
September 20th, 2001, 10:58 AM
How is possible to know the end of a process?
For example, I have n processes and I want to be advertised when a process has ended and which process has ended.
Thanks
Renzo
Iouri
September 20th, 2001, 11:01 AM
private Declare Function CloseHandle Lib "kernel32" (byval hObject as Long) as Long
private Declare Function WaitForSingleObject Lib "kernel32" (byval hHandle as Long, byval dwMilliseconds as Long) as Long
private Declare Function OpenProcess Lib "kernel32" (byval dwDesiredAccess as Long, byval bInheritHandle as Long, byval dwProcessId as Long) as Long
private Const SW_HIDE = 0
private Const SW_SHOW = 5
private Const STANDARD_RIGHTS_REQUIRED = &HF0000
private Const SYNCHRONIZE = &H100000
Const PROCESS_ALL_ACCESS = STANDARD_RIGHTS_REQUIRED Or SYNCHRONIZE Or &HFFF
Const WAIT_TIMEOUT = &H102
public Sub ShellWait(byval FileName as string, optional WindowStyle as Variant)
Dim idProc as Long
Dim hProc as LongidProc = VBA.Shell(FileName, WindowStyle)
hProc = OpenProcess(PROCESS_ALL_ACCESS, false, idProc)
If hProc <> 0 then
Do While WaitForSingleObject(hProc, 100) = WAIT_TIMEOUT
DoEvents
Loop
CloseHandle hProc
End If
End Sub
private Sub Command1_Click()
Call ShellWait("notepad.exe", SW_SHOW)
End Sub
Iouri Boutchkine
iouri@hotsheet.com