Skip over navigation

Resource File Unit

Classes for manipulating Windows 32 bit resource files

Version 1.1.0
Released 2014-01-16
Platforms Win32 & Win64
Framework RTL
Compatibilty Delphi 7 & later

Overview

This unit contains classes that encapsulate Windows 32 bit binary resource files and the resources contained in them. The main functionality is provided by two classes:

TPJResourceFile

Encapsulates the contents of a whole resource file and provides methods and properties for reading, finding, editing, adding and deleting resources. Resource file content can be read from and written to files or streams.

TPJResourceEntry

Encapsulates a single resource within the file and provides properties to access its header record and its raw data. The class also has methods to check the identity of the resource. The resource's raw data is accessible both as an array of bytes and via a TStream interface.

This class has no knowledge of resource data formats and sees the data simply as a raw sequence of bytes. It is for the user of the class to interpret the data correctly.

In addition to the two main classes, some helper functions are also provided that assist in working with resource identifiers.

An exception class – EPJResourceFile – is also defined. Exceptions of this class are raised by both the main classes when errors are encountered.

Some constants are defined for use with the memory flags field of resource header records. The RT_HTML and RT_MANIFEST resource types are also defined since they are not defined by Delphi.

No demo programs are included in the download. However the online documentation contains numerous worked examples.

Get The Code

You can download the latest version of the Resource File Unit directly from SourceForge as dd-resfile-1.1.0.zip.

Download v1.1.0

The Resource File Unit source code is hosted in the ddablib/resfile GitHub repository. You can git clone or fork the repository as required.

Installation

The Resource File Unit is supplied in a zip file. Before installing you need to extract all the files from the zip file, preserving the directory structure. The following files will be extracted:

  • PJResFile.pas – source code.
  • ReadMe.htm – read-me file.
  • ChangeLog.txt – project change log.
  • MPL-2.txt – the Mozilla Public License v2.0.
  • Documentation.URL – short-cut to the unit's online documentation.

There are three possible ways to use the unit.

  1. The simplest way is to add PJResFile.pas to your projects as you need it.
  2. To make the unit easier to re-use you can either copy it to a folder on your Delphi search path, or add the folder where you extracted the unit to the search path. You then simply use the unit as required without needing to add it to your project.
  3. For maximum portability you can add the unit to a Delphi design time package. If you need help doing this see here.

Documentation

The Resource File Unit is comprehensively documented online here

The project's change log can be viewed here.

A read-me file (ReadMe.htm) is included in the project download.

Feedback & Queries

If you find any bugs or want to suggest a new feature please report them using the Resource File Unit issue tracker.

If you have created a bug fix or have implemented a new feature please open a pull request for it.

Should you have any queries about using the unit please read the documentation. If you can't find an answer in the documentation then post a message in the discussion group.

License

The Resource File Unit is open source. It is copyright © 2004-2014 by Peter Johnson. The source code is made available under the terms of the Mozilla Public License v2.0. All relevant trademarks are acknowledged.