Solved

launch app question and wait until loaded

Posted on 1998-06-29
12
266 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
Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

 

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

Live: Real-Time Solutions, Start Here

Receive instant 1:1 support from technology experts, using our real-time conversation and whiteboard interface. Your first 5 minutes are always free.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Wininet read php file from internet issue 6 90
indy Tmemory stream non latin charcter issue 2 110
CheckListBox usage 3 58
Graphics32 under Delphi 10.1 Berlin 2 60
This article explains how to create forms/units independent of other forms/units object names in a delphi project. Have you ever created a form for user input in a Delphi project and then had the need to have that same form in a other Delphi proj…
Have you ever had your Delphi form/application just hanging while waiting for data to load? This is the article to read if you want to learn some things about adding threads for data loading in the background. First, I'll setup a general applica…
Microsoft Active Directory, the widely used IT infrastructure, is known for its high risk of credential theft. The best way to test your Active Directory’s vulnerabilities to pass-the-ticket, pass-the-hash, privilege escalation, and malware attacks …
This video shows how to quickly and easily add an email signature for all users on Exchange 2016. The resulting signature is applied on a server level by Exchange Online. The email signature template has been downloaded from: www.mail-signatures…

813 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

18 Experts available now in Live!

Get 1:1 Help Now