Solved

launch app question and wait until loaded

Posted on 1998-06-29
12
271 Views
Last Modified: 2010-04-04
I am launching powerpoint from my app, but when I launch it, I want my app to stay open until powerpoint is fully loaded and on the screen (this may take up to 10 sec. on a slower machine) so that the user doesn't see my app close and then wonder if powerpoint got launched. Is there anyway to have my app wait until powerpoint is visible and fully loaded before it terminates?
0
Comment
Question by:billy1
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 5
  • 4
  • 2
  • +1
12 Comments
 
LVL 5

Expert Comment

by:ronit051397
ID: 1356313
Use  WaitForInputIdle:

var
   pi: TProcessInformation;
   si: TStartupInfo;
begin
    FillMemory( @si, sizeof( si ), 0 );
    si.cb := sizeof( si );
      CreateProcess(Nil, 'NotePad', Nil, Nil,False, NORMAL_PRIORITY_CLASS, Nil, Nil, si, pi );
      WaitForInputIdle(pi.hProcess, INFINITE);//wait until the process terminates
      CloseHandle( pi.hProcess );
      CloseHandle( pi.hThread );
end;
0
 
LVL 5

Expert Comment

by:ronit051397
ID: 1356314
>//wait until the process terminates
I ment    //wait until the process is fully loaded
0
 

Author Comment

by:billy1
ID: 1356315
does the createprocess act like a shell execute... (can I still pass command line params to it to launch a specified file?)

Here's the real issue, I know where my presentation file is going to be, but powerpoint can be anywhere. I am launching the presetntation now based on the association made in the registry using the shell execute. Do I have to change this to a createprocess? and if so can i still launch the file based off of the association with powerpoint w/o knowing the location of powerpnt.exe?
0
VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

 

Author Comment

by:billy1
ID: 1356316
does the createprocess act like a shell execute... (can I still pass command line params to it to launch a specified file?)

Here's the real issue, I know where my presentation file is going to be, but powerpoint can be anywhere. I am launching the presetntation now based on the association made in the registry using the shell execute. Do I have to change this to a createprocess? and if so can i still launch the file based off of the association with powerpoint w/o knowing the location of powerpnt.exe?
0
 

Author Comment

by:billy1
ID: 1356317
sorry about the double entry!
0
 
LVL 3

Expert Comment

by:AndreasSchindler
ID: 1356318
uses Comobj;

procedure TForm1.Button1Click(Sender: TObject);
var
  pp: Variant;
begin
  try
    pp := CreateOleObject('Powerpoint.Application');
    pp.visible:=true;
    Application.terminate;
  except
    ShowMessage('Could not start Microsoft Powerpoint.');

    Exit;
  end;
end;


0
 
LVL 5

Expert Comment

by:ronit051397
ID: 1356319
CreateProcess is more or less the same as ShellExecute, just better because you can set extra parameters. If you need to call an EXE file it's better you use CreateProcess as I have just showed you.
If you need to activate an EXE with some File then fill the lpCommandLine parameter.
For example, to open a Notpad with the file bootlog.txt located in c:\, write:
CreateProcess(nil, 'NotePad c:\bootlog.txt', nil, Nil,False, NORMAL_PRIORITY_CLASS, Nil, Nil, si, pi );
0
 

Author Comment

by:billy1
ID: 1356320
i have to give the points to ronit for this one. i didn't want to use ole and the create process works great. ronit - post an answer so i can give you the points.
0
 
LVL 3

Expert Comment

by:vladika
ID: 1356321
Or you can use ShellExecuteEx, set SEE_MASK_NOCLOSEPROCESS
and use WaitForInputIdle.
It's compromise.
0
 

Author Comment

by:billy1
ID: 1356322
andreas,

do you know of a way to create an ole object as a child mdi form? This could be an even better way to solve my problem.

bill
0
 
LVL 5

Accepted Solution

by:
ronit051397 earned 100 total points
ID: 1356323
OK.
0
 
LVL 3

Expert Comment

by:AndreasSchindler
ID: 1356324
For Powerpoint in an MDI Child you only need to Create an MDI Child, insert an OLE Container, double Click on Ole Container for Associating an Object (New object or file).

That's all.
0

Featured Post

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

The uses clause is one of those things that just tends to grow and grow. Most of the time this is in the main form, as it's from this form that all others are called. If you have a big application (including many forms), the uses clause in the in…
Introduction I have seen many questions in this Delphi topic area where queries in threads are needed or suggested. I know bumped into a similar need. This article will address some of the concepts when dealing with a multithreaded delphi database…
Michael from AdRem Software explains how to view the most utilized and worst performing nodes in your network, by accessing the Top Charts view in NetCrunch network monitor (https://www.adremsoft.com/). Top Charts is a view in which you can set seve…
If you’ve ever visited a web page and noticed a cool font that you really liked the look of, but couldn’t figure out which font it was so that you could use it for your own work, then this video is for you! In this Micro Tutorial, you'll learn yo…
Suggested Courses
Course of the Month3 days, 13 hours left to enroll

630 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