[Last Call] Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 369
  • Last Modified:

Embed an external EXE in Delphi App

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
a_d_m_i_n
Asked:
a_d_m_i_n
  • 3
1 Solution
 
intheCommented:
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
 
intheCommented:
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
 
intheCommented:
..tested it yet ?
0
 
a_d_m_i_nAuthor Commented:
Yeah.

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

Thanks!
0

Featured Post

New feature and membership benefit!

New feature! Upgrade and increase expert visibility of your issues with Priority Questions.

  • 3
Tackle projects and never again get stuck behind a technical roadblock.
Join Now