Solved

How to determine if a program that i have started has finished loading

Posted on 2003-11-17
6
267 Views
Last Modified: 2010-04-17
I need to know how to determine if a program that i have started with a call to CreateProcess() has finshed loading. I have developed a program that starts and stops programs all over a network and need to send messages to tell the programs to turn on or off but have to wait until they are through loading or sometimes the message isnt processed. I have the ProcessId, ThreadId and Handle of each program and am at this point saving their titles and sending the message after i find the title on the screen (very inefficient). If any one can help...
0
Comment
Question by:derekthompson
6 Comments
 
LVL 22

Accepted Solution

by:
cookre earned 25 total points
ID: 9768787
if (0==CreateProcess(NULL,TempStr,NULL,NULL,FALSE,0,NULL,NULL,&StartInfo,&ProcInfo))
   {
   ...Unable to spawn
   }
else
  {
  Stati=0;
  lRC=GetExitCodeProcess(ProcInfo.hProcess,&Stati);
  while (lRC && Stati==STILL_ACTIVE)
          {
          Sleep(500);
          lRC=GetExitCodeProcess(ProcInfo.hProcess,&Stati);
          }
  }

Of course, no need for a loop to wait for it, just call GetExitCodeProcess() whenever you want to check and see if it returns STILL_ACTIVE.

0
 
LVL 1

Assisted Solution

by:rgenius
rgenius earned 25 total points
ID: 9768932
i did something similar, but what i did was to create entries in a database for each user. once my program is executed, i add an entry to a table. when the user exists, i delete the entry.

simple but it works for me..  just a thought.... :-)
0
 

Author Comment

by:derekthompson
ID: 9771272
im running some tests with this now but i dont think this is really any different that what im using now to detect if its been started, while (!IsWindow(hWnd)), the problem (i think) is the programs i am starting are all written in VB and are loading a common DLL they are using to load their window frame so if you watch real closely you can see the window actually change its name form ShellClient to the program name. If they receive a message during this time to start processing, for some resaon the message isnt processed (sending a msg of VK_F5 to start processing) which im pretty sure is due to the shellclient dll being loaded. The problem would be pretty simple to solve if the stupid things didnt take so long to load the dll. Some times a program can take as long as 30 sec to open (how inefficient is that) and other times the same program will open in less than a second. I put a timer in my program for a delay but its inefficient because of the inconstency of the time it takes to start up the other programs which results in A.my program seems slow because im waiting too long for other programs to start or B.not all of the programs start processing. I thought getting the actual title from the window for each added program would do the trick but i can watch in task manager and see the name of the program but it isnt on the screen yet which im pretty sure is when my program is sending the F5 message and its getting ignored. At this point i feel the only hope i have is if i can somehow tell if the window is actually visible to the user (if this is possible) but im not really for sure of anything. all comments are appreciated i still may be going down the wrong path
0

Featured Post

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

Suggested Solutions

Title # Comments Views Activity
fix34  challenge 9 96
triangle challenge 4 77
How Complex Is This Java Course ? 9 62
listing all functions in JavaScript 19 101
Here we come across an interesting topic of coding guidelines while designing automation test scripts. The scope of this article will not be limited to QTP but to an overall extent of using VB Scripting for automation projects. Introduction Now…
If you’re thinking to yourself “That description sounds a lot like two people doing the work that one could accomplish,” you’re not alone.
Viewers will learn how to properly install Eclipse with the necessary JDK, and will take a look at an introductory Java program. Download Eclipse installation zip file: Extract files from zip file: Download and install JDK 8: Open Eclipse and …
In this seventh video of the Xpdf series, we discuss and demonstrate the PDFfonts utility, which lists all the fonts used in a PDF file. It does this via a command line interface, making it suitable for use in programs, scripts, batch files — any pl…

708 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

14 Experts available now in Live!

Get 1:1 Help Now