Wait for process to end

Give the hwnd of a window can someone supply me with the code to wait for it to end processing?

Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Éric MoreauSenior .Net ConsultantCommented:
ampapaAuthor Commented:
emoreau, WSH is out as a solution. Thanks.

Michael, this process is already running so the second part of the suggested answer won't work and the first part doesn't seem to. Even though the process stopped process or was hidden, the event never fired.
Ultimate Tool Kit for Technology Solution Provider

Broken down into practical pointers and step-by-step instructions, the IT Service Excellence Tool Kit delivers expert advice for technology solution providers. Get your free copy now.

use this:

the only change u need to make to the code is to take off the section running the exe and jus do a:

ret& = WaitForSingleObject(proc.hProcess, INFINITE)

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
ampapaAuthor Commented:
A couple of questions.

The 'proc' in "WaitForSingleObject(proc.hProcess, INFINITE)" is a HWND? to the process that was started with the shell application is that correct? So they are getting the HWND using 'SHELL', the process that I am using is already running so do I need to identify the HWND and PID of it and then supply it to the 'WaitForSingleObject' function ?
Karl Peterson's site has a sample with three solutions to shell and wait.

Click "Samples" from the menu and then scroll down to the item listed as Shell32.zip
ampapaAuthor Commented:
This process has not been 'shelled' but is currently a running process. So, essentially I want to be able to wait for a process to end given a HWND and or PID.

It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Visual Basic Classic

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.