I have an application that should run several other applications in the chain. I run them through ShellExecuteEx . The order of launch of each of the applications is very important, because they depend on each other. For example:
Start(App1); If App1.IsRunning then Start(App2); If App2.IsRunning then Start(App3); ......................... If App(N-1).IsRunning then Start(App(N));
Everything works fine, but there is one possible problem: ShellExecuteEx launches the application and returns almost immediately. A problem can arise when, for example, App1 started correctly, but has not completed some internal tasks, it is not yet ready for use. But ShellExecuteEx already launches App2 , which depends on App1 , and App2 does not start properly, because it needs fully initialized App1 .
Please note that I do not want to wait for the App(N-1) to complete and then launch AppN .
I do not know if this can be solved using ShellExecuteEx, I tried to use
SEInfo.fMask := SEE_MASK_NOCLOSEPROCESS or SEE_MASK_NOASYNC;
but without any effect.
After starting the AppN application, I have a process handle. If I assume that the application is initialized after creating its main window (all applications have a window), can I somehow put a hook in the message queue and wait until WM_CREATE or maybe WM_ACTIVATE appears? When I click on such a message, my application will know that it can move on.
This is just an idea. However, I do not know how to put such a hook. So if you could help me with this or you have a better idea, that would be great :)
In addition, the solution should work in Windows XP and higher.
Thank you for your time.
Edited
@Cosmic Prund: I do not understand why you deleted your answer? I could try your idea ...
Wodzu
source share