Solved

launch app question and wait until loaded

Posted on 1998-06-29
12
262 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
  • 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
 

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
IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

 
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

What Should I Do With This Threat Intelligence?

Are you wondering if you actually need threat intelligence? The answer is yes. We explain the basics for creating useful threat intelligence.

Join & Write a Comment

Objective: - This article will help user in how to convert their numeric value become words. How to use 1. You can copy this code in your Unit as function 2. than you can perform your function by type this code The Code   (CODE) The Im…
Creating an auto free TStringList The TStringList is a basic and frequently used object in Delphi. On many occasions, you may want to create a temporary list, process some items in the list and be done with the list. In such cases, you have to…
It is a freely distributed piece of software for such tasks as photo retouching, image composition and image authoring. It works on many operating systems, in many languages.
You have products, that come in variants and want to set different prices for them? Watch this micro tutorial that describes how to configure prices for Magento super attributes. Assigning simple products to configurable: We assigned simple products…

759 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

19 Experts available now in Live!

Get 1:1 Help Now