I have a little pop3 thing I'm working on that launches my default email
program like this:
RetVal = ShellExecute(Me.hWnd, "open", PathToApplication, _
FileName, vbNullString, SW_SHOWNORMAL)
This works fine, but my question is, is there a way to know when the
launched program closes?
Thanks for any help.

Signature
Dale
ZipDC - 31 Jul 2004 09:45 GMT
> I have a little pop3 thing I'm working on that launches my default email
> program like this:
[quoted text clipped - 6 lines]
>
> Thanks for any help.
Hello
Lots of ways to do this, below is a function fire the process (and hide with
the flags shown) and another to test and see whether it has terminated or
not.
Hope this helps
ZipDC.
'Process monitoring
Private Const INFINITE = -&H1
Private Const SYNCHRONIZE = &H100000
Private Const STILL_ACTIVE = &H103
Private Const PROCESS_QUERY_INFORMATION As Long = &H400
Private Const PROCESS_TERMINATE As Long = &H1
Private Declare Function OpenProcess Lib "kernel32" (ByVal dwDesiredAccess
As Long, ByVal bInheritHandle As Long, ByVal dwProcessId As Long) As Long
Private Declare Function GetExitCodeProcess Lib "kernel32" (ByVal hProcess
As Long, lpExitCode As Long) As Long
Private Function ShellAndContinue(ByVal AppToRun As String) As Long
Dim hProcess As Long
Const dwAccess As Long = PROCESS_QUERY_INFORMATION Or SYNCHRONIZE Or
PROCESS_TERMINATE
'The next line launches AppToRun, captures process ID
hProcess = OpenProcess(dwAccess, 1, Shell(AppToRun, vbHide))
ShellAndContinue = hProcess
End Function
Private Function MonitorProcess(ByVal hProcess As Long) As Boolean
'Function to detrmine if process is still active
Dim Retval As Long
GetExitCodeProcess hProcess, Retval
If Retval = STILL_ACTIVE Then
MonitorProcess = True
Else
MonitorProcess = False
End If
End Function
J French - 31 Jul 2004 14:17 GMT
>I have a little pop3 thing I'm working on that launches my default email
>program like this:
[quoted text clipped - 4 lines]
>This works fine, but my question is, is there a way to know when the
>launched program closes?
Do a groups Google for "Shell and Wait"