[Delphi] embed another exe file in the exe file of delphi

Source: Internet
Author: User

Principle:

Put the exe that needs to be included into the input source file, compile it with the original program into an exe file, release the exe when the program runs for the first time, and then call the exe file.

 

Steps:

1. Create an rc file. It can be written in any text editor. File Format: "Resource Name resource type file name ".

For the resource type, if it is an exe file, it should be an EXEFILE, and if it is a binary file, it is RCDATA.

Create a file float. rc:

Code

1 aexe exefile "E: \ Software \ float.exe"

 

2. Convert the rc file to the res file.

Copy float. rc to the bin folder in the DELPHI installation directory, execute brcc32 float. rc, and generate float. res.

 

3. Include this res file into the project file.

Code

1 {$ R float. res}

4. Extract float. EXE from RES.

 

Code

1 procedure TFormMain. IEEE7541Click (Sender: TObject );
2
3 var
4 t: TResourceStream;
5 begin
6
7 if FileExists('float.exe ') then
8 WinExec('float.exe ', Sw_normal)
9 else
10 begin
11 try
12 t: = TResourceStream. Create (HInstance, 'aexe ', 'exefile'); // HInstance is a handle constant, rwww is the resource name, And EXEFILE is the resource type.
13 t.SaveToFile('float.exe ');
14 finally
15 t. free;
16 end;
17 WinExec('float.exe ', Sw_normal );
18 end;
19 end;

 

In this way, you can call another exe program in an exe file.

 


Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.