There is, the procedure is simple to do!
You will use the BRCC32
which is also responsible for generating the Resources for Delphi!
Let’s create a test!
- 1 - Create and save a project with only 1 button in the form.
- 2 - In the folder where the project sources were saved, copy to the same
the file
BRCC32.EXE
that this in Delphi installation bin folder (I always prefer to copy).
- 3 - Add an executable file of your choice in this folder!
- 3.1 - Create a text file (any name) with the following structure (without the explanatory header) in the saved project folder
formerly.
Resource Name - Identifier - File Path to be attached
Arquivoteste Exes "full project folder path
file and its extension" (3 vestments, the last one should be in quotes
doubles)
- 3.2 - Change the extension on this file
.txt
for .rc
- 4 - We have everything ready to create our resource archive!
- 4.1 - On Windows Run: 'Folder Path' brcc32' 'filename created in 3.1 with extension' (do not use quotes ex:
c:\temp\teste\brcc32 nome_desejado.rc
)
- 4.2 - Note that in the project folder a new file with the same name was created
.rc
with the extent .res
- 5 - Open the project and below {$R *.DFM} add {$R name of
res files with extension}
- 6 - In the event click of the button we will perform the Extraction of the executable
to be used by the system.
procedure frmTeste.btnIniciarClick(Sender: TObject);
var
Stream: TResourceStream;
begin
Stream := TResourceStream.Create(hInstance, 'ArquivoTeste', 'EXEs'); //Nome do recurso criado e Tipo
try
Stream.SaveToFile('caminho_completo\ArquivoTeste.exe'); //ex: c:\temp\teste\ArquivoTeste.exe
finally
Stream.Free;
end;
end;
- 7 - Compile the project, to make sure it all worked out, delete the
RC files, RES, and the executable that was attached!
- 7.1 - Run the application and test!
Some features can be used in memory, not needing to do the extraction!
This script I just put together, if there is something wrong or procedure that failed let me know that I make the correction!
Just to make sure I understand perfectly, you want to use the program made in Delphi 5 as a resource to be called by the program made in Delphi XE8?
– DH.
I did not see much sense, but you can include as a resource. It is not advisable in this case, but may include. In Delphi 7 had a compilation instruction. I think it was {$R 'filename'}, just as Delphi already included DFM’s in the resource (there is a command of this in each form).
– Andre Mesquita
@Darkhyudra otherwise, I want to embed an EX8 in a 5
– Gabriel Rodrigues
The hole is very deep, and there is a code that a little gringo guy did once, but I can’t promise you that it works in Delphi 5. In this question of the OS, in the first answer has the link to Unit used and more details of how to use it: http://stackoverflow.com/questions/6395493/execute-an-exe-file-from-resource-into-memory
– DH.