Solved

Embed an external EXE in Delphi App

Posted on 2000-05-13
4
364 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

On Demand Webinar - Networking for the Cloud Era

This webinar discusses:
-Common barriers companies experience when moving to the cloud
-How SD-WAN changes the way we look at networks
-Best practices customers should employ moving forward with cloud migration
-What happens behind the scenes of SteelConnect’s one-click button

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Delphi XE10 Round Image 2 184
Run video youtube webbrowse 10 73
JAudiorecorder record freezing the app 29 82
Delphi: sending SMS on android platform 1 61
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…
Introduction Raise your hands if you were as upset with FireMonkey as I was when I discovered that there was no TListview.  I use TListView in almost all of my applications I've written, and I was not going to compromise by resorting to TStringGrid…
How to Install VMware Tools in Red Hat Enterprise Linux 6.4 (RHEL 6.4) Step-by-Step Tutorial
Attackers love to prey on accounts that have privileges. Reducing privileged accounts and protecting privileged accounts therefore is paramount. Users, groups, and service accounts need to be protected to help protect the entire Active Directory …

685 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