-----------------------------------------------------------

New Message on BDOTNET

-----------------------------------------------------------
From: Sitaraman
Message 5 in Discussion

Hi Vineet   Guess Arun's Problem is not in sending the mail, but making the "Mail 
Sending Process" wait till the "File Zipping Process" is over.  Some time back  we had 
a similar problem and could not look into it myself due to time constraints. So my 
client wrote this snippet for me to make the shell cmd wait till the time the shelled 
process is over :)  Here u go      Option Explicit 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 Declare Function CloseHandle Lib "kernel32" (ByVal hObject As Long) As Long 
Const STILL_ACTIVE = &H103&
Const PROCESS_QUERY_INFORMATION = &H400&   Sub main()
runCommand ("winword")
End Sub   Sub runCommand(p_strCommand As String)     Dim lTaskID As Long
    Dim lProcHandle As Long
    Dim lExitCode As Long
    Dim lReturnCode As Long     lTaskID = Shell(p_strCommand, vbNormalFocus)
    
    'Get the Process Handle based on the Process id
    lProcHandle = OpenProcess(PROCESS_QUERY_INFORMATION, 1, lTaskID)
    
    'Loop till the time the process is executing
    Do
        lReturnCode = GetExitCodeProcess(lProcHandle, lExitCode)
        DoEvents     Loop While lExitCode = STILL_ACTIVE
    
    'Close the Process Handle
    CloseHandle lProcHandle
    MsgBox "done"
End Sub      Here note that we are trapping the return value of the Shell command, 
which is the process if and using api functions we track the status of the process.  
we loop till the time the process is executing and exit the loop when the process is 
over.  you can simply copy paste the whole snippet(execpt for the dummy main method) 
above in your code and call the runcommand method instead of the shell command.     
regards,   sr   I have posted a reply for ur post on this same subject in chennai user 
group also. But that text  might have some problems as it contained the original 
japanese comments(ccp mistake ;) )

-----------------------------------------------------------

To stop getting this e-mail, or change how often it arrives, go to your E-mail 
Settings.
http://groups.msn.com/BDotNet/_emailsettings.msnw

Need help? If you've forgotten your password, please go to Passport Member Services.
http://groups.msn.com/_passportredir.msnw?ppmprop=help

For other questions or feedback, go to our Contact Us page.
http://groups.msn.com/contact

If you do not want to receive future e-mail from this MSN group, or if you received 
this message by mistake, please click the "Remove" link below. On the pre-addressed 
e-mail message that opens, simply click "Send". Your e-mail address will be deleted 
from this group's mailing list.
mailto:[EMAIL PROTECTED]

Reply via email to