Solved

Running another application from within an app

Posted on 1998-11-19
3
141 Views
Last Modified: 2010-04-04
I have a large application which requires a custom written print engine to be running in the background. Occasionally I have found users closing down this print engine, thus stopping any more printing being done.

Can anyone suggest a way of first checking if the print engine is running or not. One restriction I have is that I cannot access the source code of the print engine so the answer must come from modifications to my program.

Thank you for any assistance
0
Comment
Question by:psykes
  • 2
3 Comments
 
LVL 1

Expert Comment

by:sassas081597
ID: 1347302
Has your print engine any main window? In this case you can check whether the Window with specified name exists?
0
 

Author Comment

by:psykes
ID: 1347303
The print engine has a main window and will always be called by the same string, therefore I could try the method you described, except how do I check whether the specified name exists
0
 
LVL 1

Accepted Solution

by:
sassas081597 earned 100 total points
ID: 1347304
Use the function FindWindow (or FindWindowA, or FindWindowW) as shown bellow.
In this Example you write any text in EditBox and when you click a button the programm looks for a Window with the Caption exactly as in Editbox. If you get 0 - Such window does not exist else - it exists.

procedure TForm1.Button1Click(Sender: TObject);
var
    c: array[0..50] of Char;
    d: PChar;
begin
     StrPCopy(c,Edit1.Text);
     d:=nil;
     a:=;
     if (FindWindowA(d,c)<>0) then
          Caption:='Window Found'
     else
         Caption:='Window Not Found';
end;
So try this code and then write your own.
If you'd like, you can use FindWindowEx() instead of FindWindow() (look in windows.pas for its parameters).
0

Featured Post

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

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…
Hello everybody This Article will show you how to validate number with TEdit control, What's the TEdit control? TEdit is a standard Windows edit control on a form, it allows to user to write, read and copy/paste single line of text. Usua…
In an interesting question (https://www.experts-exchange.com/questions/29008360/) here at Experts Exchange, a member asked how to split a single image into multiple images. The primary usage for this is to place many photographs on a flatbed scanner…
I've attached the XLSM Excel spreadsheet I used in the video and also text files containing the macros used below. https://filedb.experts-exchange.com/incoming/2017/03_w12/1151775/Permutations.txt https://filedb.experts-exchange.com/incoming/201…

840 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