Solved

Embed an external EXE in Delphi App

Posted on 2000-05-13
4
361 Views
Last Modified: 2010-04-04
This may be something simple, but I haven't been around Delphi for a while.  In fact, I am using version 3 because I bought that version a few years ago and now I am being asked to create a simple app.

My question is ...  can I embed a stand-alone EXE app into my Delphi EXE.  I would like to do this so that a user would have to launch my EXE and would not be able to browse to the other one to launch that one.

Thanks.
0
Comment
Question by:a_d_m_i_n
  • 3
4 Comments
 
LVL 17

Accepted Solution

by:
inthe earned 100 total points
ID: 2807269
hi,
you can add them to your resource file then extract them from there
example:


make a .rc file (in notepad etc ) that looks like:

 TESTFILE1  EXEFILE C:\TEST1.EXE
 TESTFILE2  EXEFILE C:\TEST2.EXE

and save as myres.rc.
compile with brcc32 to get myres.res

then in unit do:

{$R *.DFM}
{$R MYRES.RES}
procedure ExtractRes(ResType, ResName, ResNewName : String);
var
  Res : TResourceStream;
begin
  Res := TResourceStream.Create(Hinstance, Resname, Pchar(ResType));
  Res.SavetoFile(ResNewName);
  Res.Free;
end;


on form activate or button click
you could show a memo or somethng with the files names and extract them etc..

procedure TForm1.Button1Click(Sender: TObject);
begin
ExtractRes('EXEFILE','TESTFILE1','C:\TEST1_EXE_FROM_RES.EXE');
ExtractRes('EXEFILE','TESTFILE2','C:\TEST2_EXE_FROM_RES.EXE');

end;


Regards Barry
0
 
LVL 17

Expert Comment

by:inthe
ID: 2807272
you can then use shellexecute etc (from shellapi.pas) or winexec(filename,sw_normal)to start the files and when finished can use deletefile(filename) to delete it..
0
 
LVL 17

Expert Comment

by:inthe
ID: 2813812
..tested it yet ?
0
 

Author Comment

by:a_d_m_i_n
ID: 2821259
Yeah.

Sorry for the delay.  I have been trying to tweak it a bit.  Your suggestion is a good one.

Thanks!
0

Featured Post

Top 6 Sources for Identifying Threat Actor TTPs

Understanding your enemy is essential. These six sources will help you identify the most popular threat actor tactics, techniques, and procedures (TTPs).

Join & Write a Comment

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…
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…
Internet Business Fax to Email Made Easy - With eFax Corporate (http://www.enterprise.efax.com), you'll receive a dedicated online fax number, which is used the same way as a typical analog fax number. You'll receive secure faxes in your email, fr…
In this tutorial you'll learn about bandwidth monitoring with flows and packet sniffing with our network monitoring solution PRTG Network Monitor (https://www.paessler.com/prtg). If you're interested in additional methods for monitoring bandwidt…

746 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

12 Experts available now in Live!

Get 1:1 Help Now