Solved

launch app question and wait until loaded

Posted on 1998-06-29
12
269 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
Networking for the Cloud Era

Join Microsoft and Riverbed for a discussion and demonstration of enhancements to SteelConnect:
-One-click orchestration and cloud connectivity in Azure environments
-Tight integration of SD-WAN and WAN optimization capabilities
-Scalability and resiliency equal to a data center

 

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

Networking for the Cloud Era

Join Microsoft and Riverbed for a discussion and demonstration of enhancements to SteelConnect:
-One-click orchestration and cloud connectivity in Azure environments
-Tight integration of SD-WAN and WAN optimization capabilities
-Scalability and resiliency equal to a data center

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
add combobox item based on numbers 9 154
When I am typing into a TEdit last word repeats 7 148
select query - oracle 16 100
When i run adoquery my application freezes 26 181
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 The parallel port is a very commonly known port, it was widely used to connect a printer to the PC, if you look at the back of your computer, for those who don't have newer computers, there will be a port with 25 pins and a small print…
Although Jacob Bernoulli (1654-1705) has been credited as the creator of "Binomial Distribution Table", Gottfried Leibniz (1646-1716) did his dissertation on the subject in 1666; Leibniz you may recall is the co-inventor of "Calculus" and beat Isaac…

820 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