Welcome to the new DelphiDabbler Code Library Documentation.

This is a new site that's currently running on alpha code. There are going to be bugs. If you discover any, please report them on the site's issues page (GitHub account required). Thanks.

Warning: Many URLs are going to change. Refer to the README file to discover which library project's documentation has been completed.


Project: Resource File Unit

Unit: PJResFile.

Applies to: ~>1.0

This class is used to encapsulate a 32 bit resource file, to find which resources it contains, to add new resources and to delete existing ones.

Create new, empty instances of TPJResourceFile by calling its parameterless Create constructor.

Resource entries accessed or created via this class are TPJResourceEntry objects and have methods and properties that can be used to interrogate and update them. These objects are not created directly but are created by loading a resource file or by calling methods of TPJResourceFile.

Freeing a TPJResourceFile instance also frees all the associated TPJResourceEntry objects, so do not keep references to these objects after the parent TPJResourceFile object has been freed.

When compiled with Delphi 2005 and later all the resource entries in a TPJResourceFile instance can be enumerated within a for..in loop.

Note: Although we use the term “resource file” in this documentation, the term also relates to binary resource data stored in a stream.


Method Description
AddEntry Overloaded methods that add a new, empty, resource to the object.
Clear Clears all resource entries from the resource file.
DeleteEntry Deletes a given resource entry object from the resource file.
EntryExists Checks if a resource with a given type, name and language ID exists.
FindEntry Finds a resource by type, name and language ID.
FindEntryIndex Finds the index of a resource in the Entries property by type, name and language ID.
GetEnumerator [~>1.1] Returns an object that can enumerate all the resource entries in a resource file.
IndexOfEntry Gets the index of a resource entry in the Entries property.
IsValidResourceStream Class function that checks if a stream contains a valid 32 bit resource file.
LoadFromFile Loads data from a resource file.
LoadFromStream Loads resource data from a stream.
SaveToFile Saves resource data to a file.
SaveToStream Saves resource data to a stream.


Property Description
EntryCount Number of resources (entries) in the resource file.
Entries Indexed access to all resources in the resource file.