Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

Exe Control

Posted on 1999-07-21
9
Medium Priority
?
213 Views
Last Modified: 2010-04-04
In a local database app, I need a way to make the subordinate exe's dependent on the main form in order to implement the database login.  Without the main exe running, the sub exe's won't run.
0
Comment
Question by:henrylim
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 4
  • 3
  • 2
9 Comments
 
LVL 10

Expert Comment

by:viktornet
ID: 1390319
not sure what you mean... sorry..
0
 
LVL 17

Accepted Solution

by:
inthe earned 120 total points
ID: 1390320
Hi
well i can think of 2 ways tyhat could help either use findwindow(app1 hwnd) to see if app 1 is running
or get app 1 to write a boolean value in the registry on it's startup which then app2 and app 3 can look for on their startup.
on app1 close event change the key to a false in the registry.
Regards Barry
0
 
LVL 10

Expert Comment

by:viktornet
ID: 1390321
oh i see now... you can use FindExecutable() in order to find the path to your MAN EXE file...

Good Luck!!

..-=ViKtOr=-..
0
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 10

Expert Comment

by:viktornet
ID: 1390322
MAN=MAIN
0
 
LVL 17

Expert Comment

by:inthe
ID: 1390323
MAN=MAIN <--True in my house anyway  ;-)
0
 

Author Comment

by:henrylim
ID: 1390324
Hi Inth,
I'm pretty new to Delphi programming, could you show me how ?
0
 
LVL 17

Expert Comment

by:inthe
ID: 1390325
hi,
sure i give example just send me a email to me at legend@enterprise.net and i'll send you back a example of doing this..
Regards Barry
0
 
LVL 17

Expert Comment

by:inthe
ID: 1390326
nevermind here is examples.
after building these the second unit1 will only run if the first unit1 is already running.

app1 look like this:


unit Unit1;

interface

uses
  Windows,Registry, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs;

type
  TForm1 = class(TForm)
    procedure FormCreate(Sender: TObject);
    procedure FormDestroy(Sender: TObject);
  private
    { Private declarations }
  public
    { Public declarations }
  end;

var
  Form1: TForm1;

implementation

{$R *.DFM}

procedure TForm1.FormCreate(Sender: TObject);
Var r: TRegistry;
      a: bool;    
{  remember to add registry to the uses section ,it is not normally there.}
begin
a:= true;  //a is our boolean value we set to true
           //because the app is now running
r := TRegistry.Create;
r.RootKey := HKEY_LOCAL_MACHINE;       //set the registrys rootkey
 with r do
 try
 CreateKey('Software\NameOfMyProgram');   //create the registry key
 OpenKey('Software\NameOfMyProgram', False); //open it
 WriteBool('IsRunning',a);    //write our value to the registry
{look in  delphi help files for many other registry functions,writebinarydata,writestring,writeinteger etc}
 CloseKey;                     //close it
 finally
  free;                       //free it
 end;
end;


procedure TForm1.FormDestroy(Sender: TObject);
Var r: TRegistry;
      a: bool;
begin
a:= False;  //set key to false on form destroy
    //now when app 2 looks here it will see app 1 is not running
r := TRegistry.Create;
r.RootKey := HKEY_LOCAL_MACHINE;
 with r do
 try
 CreateKey('Software\NameOfMyProgram');
 OpenKey('Software\NameOfMyProgram', False);
 WriteBool('IsRunning',a); //commit the change to registry
 CloseKey;
 finally
  free;
 end;
end;

end.





app 2 look like this:


unit Unit1;

interface

uses
  Windows,Registry, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs;

type
  TForm1 = class(TForm)
    procedure FormCreate(Sender: TObject);
  private
    { Private declarations }
  public
    { Public declarations }
  end;

var
  Form1: TForm1;

implementation

{$R *.DFM}

procedure TForm1.FormCreate(Sender: TObject);
Var r: TRegistry;
      a: bool;
{  remember to add registry to the uses section ,it is not normally there.}
begin
a:= false;
{set A to false in case key does not exist in registry
in which case app1 has never been run so we
   cant run app2 yet.}
r := TRegistry.Create;
r.RootKey := HKEY_LOCAL_MACHINE;
 with r do
 try
 CreateKey('Software\NameOfMyProgram');
 OpenKey('Software\NameOfMyProgram', False);
 a := ReadBool('IsRunning');    //read the value into A
 CloseKey;
 finally
  free;
 end;
 if a = False then application.Terminate
end;

end.



Regards Barry


0
 

Author Comment

by:henrylim
ID: 1390327
Hi Barry,
Your tip is neat and lean.  I like it.  Thank you.
0

Featured Post

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone 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…
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 created a query with information for a calendar? ... and then, abra-cadabra, the calendar is done?! I am going to show you how to make that happen. Visualize your data!  ... really see it To use the code to create a calendar from a q…
In this video, Percona Solution Engineer Dimitri Vanoverbeke discusses why you want to use at least three nodes in a database cluster. To discuss how Percona Consulting can help with your design and architecture needs for your database and infras…
Suggested Courses

670 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