Solved

launch app question and wait until loaded

Posted on 1998-06-29
12
264 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
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 
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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
System restore point 4 91
Syntax Check Delphi Seattle IOS app without MAC ? 1 91
Delphi - replicating a form 8 64
can't find the executable in Simulator 1 80
A lot of questions regard threads in Delphi.   One of the more specific questions is how to show progress of the thread.   Updating a progressbar from inside a thread is a mistake. A solution to this would be to send a synchronized message to the…
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…
Migrating to Microsoft Office 365 is becoming increasingly popular for organizations both large and small. If you have made the leap to Microsoft’s cloud platform, you know that you will need to create a corporate email signature for your Office 365…
Video by: Mark
This lesson goes over how to construct ordered and unordered lists and how to create hyperlinks.

912 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