Link to home
Start Free TrialLog in
Avatar of Dreaming_Eagle
Dreaming_Eagle

asked on

CODE TO SHELLWAIT()

I've used this routine before, and it worked well.  Unfortunately, the source was left behind at my last job.  I'm putting 150 points on the question, because I really need to start using it tommorrow (Wednesday, 11/24).  

Thanks!

Avatar of Dreaming_Eagle
Dreaming_Eagle

ASKER

The routine I'm referring to is from "Visual Basic 5.0
Programmers Guide to the Win32 API" by Dan Appleman.
The routine I'm referring to is from "Visual Basic 5.0
Programmers Guide to the Win32 API" by Dan Appleman.
If you are looking to shell an application and wait for it to terminate, here are some code examples:

http://www.thescarms.com/vbasic/Wait.htm
http://vbaccelerator.com/codelib/shell/shelwait.htm
http://www.vb-world.net/tips/tip5.html
ASKER CERTIFIED SOLUTION
Avatar of mcrider
mcrider

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Mcrider, I liked your second approach the best.  Simply using shell then using IsShellActive in a loop as follows:

sTime = time
while IsShellActive(taskHandle)
     doEvents
     if timeout(sTime)
        exit sub
     end if
wend

I added the timeout function just in case the DOS app gets hung on the suggestion of my boss.  If it is still in the while/wend loop after 2 minutes, timeout() returns true.

I like this better than adding all the additional code to the application.  

You've got the points...just wondered if you have any further thoughts.  




Just remember, when you're in a loop doing a "DoEvents" waiting for the shelled application to terminate... You program's events will still fire.

Make sure that your code doesn't launch the DOS application more than once.

For example, let's say that you launch the looping code by clicking a CommandButton...  Setting the "Enabled" property of the CommandButton to "FALSE" before you enter the loop, and resetting it to "TRUE" after you exit the loop will insure that the user doesn't mistakenly click the button twice and launch 2 copies of the program...  Get the picure??


Cheers!

(Hoping for a "good" grade!)

;-)
Yes, preventing a second click is an excellent idea and disabling the Send Fax button, in this case, is a good way to do so.  I also think the timeout() is essential in case the Fax utility hangs for some reason.  Of course, you get a good grade, MC, for very good answer.  Thanks.
Thanks for the points!

Glad I could help.

Cheers!