Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Help with CreateProcess and WaitForSingleObject 1

Status
Not open for further replies.

asamoah

Programmer
Apr 30, 2002
5
AU
Hi all,
In my code, I am trying to create a new process to run an installation program. This program installs and registers a number of files. I don't want to continue execution of the calling application until this new process has completed its work.

So far I have been using CreateProcess(...) and WaitForSingleObject(ProcessHandle, INFINITE).
My problem is that WaitForSingleObject never seems to return to the calling program. So - we sit in what seems to be an endless 'loop' and nothing happens. If I remove WaitForSingleObject, the installation program runs fine, but my calling program runs at the same time - I need to avoid doing this.

I think the problem may lie in the fact that the installation program calls another exe from within in it - perhaps my code is not sufficient to find out when they both end??

So - What is the best way to work out when my installation program has completed execution??

thanks in advance,
Em
 
The best way, You should check, if all Your install program must do is really done - then it works allways. WaitForSingleObject() etc. for NT is not the same as for 95/98.
 
Thanks for the reply - but could you elaborate on your answer please?
I'm not 100% sure, but I think my problem has something to do with the Install program and not my program because if I substitute any other .exe in the CreateProcess it works (and waits) fine... Any ideas on that??

And just what are the differences in WaitForSingleObject between NT and 98? I wasn't aware of any...

thanks again...
Em
 
Looks to me like the installation program never ends. Perhaps it is waiting (forever) for some event to happen or some mutex to be freed after the main window has been destroyed? You can download Process Explorer from to check these things.

Marcel
 
Thanks for this tip. I have downloaded Process Explorer and am now running my program... yes it appears that the Installation.exe is waiting on a mutex. The name of the mutex is OLESCMLOCKMUTEX. I suppose this means that there's nothing I can do from my end to resolve this issue? I am fairly new to VC++ and windows programming so am not really sure about what to do.

thanks again for your help.
Em
 
If you did not write the installation program yourself, i'm afraid there is not much to do about it other than report it to the original author. If you did write it yourself, please post the code of the exit routine of the program. Is it multi-threaded?

Marcel
 
Hi,
No I did not write the installation program myself, but I can get access to the code from a colleague. It was created using InstallShield Professional - what part of this code should I post? I have made them aware of the problem I'm having, but they have not yet resolved anything at their end...

thanks for your help,
EM
 
Many times InstallShield comes with a messagebox at the end asking you to reboot or not to reboot. Are you sure there is no such thing hidden somewhere behind other windows? If this is not the case, my advise is the following:

1. After CreateProcess, find out the window handle of the main window of Installshield.
2. In a loop, Sleep for some time (eg. 5 seconds) and check if the window still exists. If yes, sleep again, etc. If no, assume Installshield has ended.

OR

Change the INFINITE in the WaitForSingleObject call to a time long enough to be sure InstallShield must have ended.

Marcel
 
Marcel,
Thanks for taking the time to help. I will try these things and see how I go.
thanks again....
Em
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top