-----------------------------------------------------------
New Message on BDOTNET
-----------------------------------------------------------
From: Sitaraman
Message 3 in Discussion
Hi Sridhar Guess Arun is using Classic VB and dont think Shell command of Vb (NOT
VB.Net) does not have wait as parameter. Only 2 params, first one is for the cmd name
and the second is the window mode. Some time back i had this problem just before our
site was moving to production and really didnt have time to look at it myself. So my
client wrote this code for me to make the calling program wait till the shell process
was 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)
'???????????
lProcHandle = OpenProcess(PROCESS_QUERY_INFORMATION, 1, lTaskID)
'?????????????
Do
'?????????
lReturnCode = GetExitCodeProcess(lProcHandle, lExitCode)
DoEvents Loop While lExitCode = STILL_ACTIVE
'?????????
'CloseHandle lProcHandle
MsgBox "done"
End Sub
Here note that u trap the return value of the Shell cmd, which is the process Id.
Using the winapi functions we can track the status of the process based on this
process id, loop until it is over and then exit. you can paste the runcommand
function in ur program and call it instead of calling shell cmd hope this helps
regards, sr
-----------------------------------------------------------
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]