Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
Discussion GroupsVB SyntaxEnterprise DevelopmentDatabase AccessControlsCOMWin APICrystal ReportDeploymentGeneralGeneral 2
Related Topics
VB.NET / ASP.NETMS SQL ServerMS AccessOther Database ProductsMore Topics ...

VB Forum / General / July 2004



Tip: Looking for answers? Try searching our database.

How to know when an app closes?

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Dale - 31 Jul 2004 07:35 GMT
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"
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2009 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.