Resource Export v1.0 (13th February 2000)
Documentation
Ó
2000 by Tom Peiffer

Features - UsageInstallation - Properties - Methods - Events - Errorcodes - Author

Features

Many users just use resource files (*.res) for the purpose of saving icons or wave files in them. After compilation, the icons and waves are included in the executable file, so that they need not to be distributed the the application.

With this component, you may include any file, also other executables, inside a resource file. The component is able to export these files again and write them to your harddisk. In this way, you can store complete other files inside your application.

Usage

  1. Build a rc-file with your notepad (e.g. demo.rc) , that describes the files that need to be included in your resource file. See the demo.rc file included in this zip-archieve for the syntax of such a rc-file. The first column is the internal resource name, the second is the resource category and the third is the filename you'd like to include in your resource file.
  2. Compile the rc-file in a DOS window by calling brc32 -r demo.rc
  3. Copy this demo.res file to your application directory.
  4. In your project, go to the implementation part and include the compiler directive {$R demo.res}
  5. Drop ResourceExport component on your form and use its properties and methods.

Take a look to the demo project and you'll see the simplicity of using this component.

Installation

Copy the 2 files (ResourceExport.pas, ResourceExport.dcr) in your component directory. In the component menu in Delphi, select Install component and choose ResourceExport.pas. The component appears on the "Tom" palette in your VCL. 

Properties

property ResourceName : string ;
The internal name of your resource. (1. column in rc-file)

property ResourceCategory : string ;
The category name of your resource. (2. column in rc-file)

property ExportFileName : string ;
The filename of the exported file that is created after calling the Execute method.

property Overwrite : boolean ;
If true, any existing file will be overwritten automatically. If fals, the OnWriteFileError event is triggered.

property Size : integer ;
After calling the execute method, this property contains the size of the exported resource.

Methods

function Execute : integer ;
This method exports the given resource to your disk. If the return value is 0, the succeeded, else an error occured. See the ErrorCodes for details on return values.

Events

OnSuccess (Sender : TObject ; BytesWritten : integer) ;
The export of the resource succeeded. In BytesWritten you get the size of bytes that have been written to your disk.

OnResourceNotFound (Sender : TObject) ;
See Errorcode reNotFound.

OnLoadResourceError (Sender : TObject) ;
See Errorcode reLoadError.

OnWriteFileError (Sender : TObject) ;
See Errorcode reFileExists.

ErrorCodes

reOK = 0 ;
reNotFound = 1 ;  (the resource name could not be found)
reLoadError = 2 ; (The resource could not be loaded)
reFileExists = 4 ; (The file could not be written to your disk because Overwrite is set to false and the file already exists)

Author

Tom Peiffer (Physics student at University of Kaiserslautern)
Hirtenweg 2
D-67661 Kaiserslautern
Germany
EMail: peiffer@rhrk.uni-kl.de

T.P. 2000