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
Applies to: ~>1.0
This class encapsulates a resource within a resource file.
TPJResourceEntry objects are used to manipulate and interrogate resource entries. Properties are exposed that give access to the resource header information, some of which can be modified by writing to properties. The resource’s raw data can be read and manipulated either through the Data property, which provides a TStream interface to the data or via the DataBytes [~>1.1] property that enables the raw data to be read and written to and from a byte array.
This is done mainly via properties which give access to resource header information, allow some header information to be set, and give read/write access to the raw resource data via a TStream or as a an array of bytes [~>1/1].
Objects of this class must not be directly instantiated. TPJResourceFile automatically creates the required objects when loading a resource file. New, empty resource entry instances can be created by using one the overloaded AddEntry methods provided by TPJResourceFile. TPJResourceEntry is actually an abstract class that provides an interface for manipulating resource entries. The concrete class that implements the resource entry is private. This enforces the rule that all valid resource objects are created and accessed via TPJResourceFile.
Care should be taken not to use a resource entry after the related resource file object has been cleared or destroyed, or a new resource file has been loaded, since all these actions free previous resource entries. It is safe to free a TPJResourceEntry object directly by calling its Free method. Doing so automatically removes the object from the resource file object it belongs to.
|ClearData [~>1.1]||Clears (deletes) the resource entry’s raw data.|
|IsMatching||Overloaded methods to check if the resource entry matches the type, name and language ID of another entry.|
|LoadDataFromFile [~>1.1]||Loads the content of a file into the resource entry’s raw data.|
|Characteristics||Gets or sets the user specified characteristics of the resource as a DWORD.|
|Data||Provides a reference to the TStream object that contains the resource’s raw data. The stream can be used to read or write the data. Any padding bytes that follow the resource’s data are not included in the stream. The object reference is read only but the stream’s contents can be modified.|
|DataBytes [~>1.1]||Provides read-write access to the resource’s raw entry as a TBytes† byte array. Reading the property returns a copy the the resource data. Assigning to the property replaces any existing resource data with a copy of the byte array being assigned and set the !Data stream’s position to the start of the stream.|
|DataSize||The size of the resource data in bytes as a DWORD value. This is the same as calling same as calling Data.Size. Read only.|
|DataVersion||Gets or sets the predefined data resource version information as a DWORD.|
|HeaderSize||The size of the resource header as a DWORD. Read only. Note that the header size varies depending on the type and size of the resource type and name.|
|LanguageID||The language used by the resource as a Word. A value of 0 is language-neutral. Read only.|
|MemoryFlags||Gets or sets the attribute bitmask that specifies the state of resource as a Word.|
|ResName||The name of the resource as a PChar. This value is either a pointer to a zero-terminated string or an ordinal value of the type returned from MakeIntResource. Read only.|
|ResType||The type of the resource as a PChar. This value is either a pointer to a zero-terminated string or an ordinal value of the type returned from MakeIntResource. Read only.|
|Version||Gets or sets the user specified version number of the resource data as a DWORD.|
† TBytes is defined in SysUtils on Delphi 2007 and later. For earlier compilers TBytes is defined in the PJResFile unit as
array of byte.