TimCS.Co.Uk Delphi Delphi Guides How to add and use an exe within a Delphi program
How to add and use an exe within a Delphi program


This guide will demonstrate how to add a file , in this case an exe program, within a Delphi program and then how to use it by extracting from the Delphi program.

Creating a resource Script file

In order to achieve this, a resource script file .rc needs to be created first. From this file, using the Delphi brcc32 command, a resource fileĀ .res will be created.

To create the resource script file the following structure is required :

ResourceName1 ResourceType1 ResourceFileLocation1
ResourceName2 ResourceType2 ResourceFileLocation2


The reference to ResourceName will be how the file is referred to in the program code, the ResourceType identifies the type of file it is and the ResourceFileLocation is where the file is currently located. In this case the name that will be used is test the resource type is RCDATA (used with other types of files such as exe) and the location will be c:\test.exe .

To create this file, simply use a text editor but save its file extension to .rc , so in the case here the file should contain one line as follows:

test RCDATA c:\test.exe


Save the filename, for this resource script file, as test.rc .

Creating a resource file

Now this has been created, it needs to be compiled as a resource file .res . To do this , open a command prompt, move to where the test.rc is located and type :

brcc32 test.rc


This will create a test.res file which now can be used within a Delphi program.


 

Powered by Joomla!. Valid XHTML and CSS. Credits go to Gareth Flowers for his help with this site.