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.

Example #7: Checking if a resource exists

If you attempt to add a duplicate of an existing resource to a resource file an exception will be raised. To avoid this we may need to check if a resource already exists. This can be done with the EntryExists method of TPJResourceFile as follows:

var
  ResFile: TPJResourceFile;
  Entry: TPJResourceEntry;
begin
  ...
  // Assume ResFile references a valid object
  ...
  if not ResFile.EntryExists(RT_RCDATA, 'FORTYTWO', $0809) then
    Entry := ResFile.AddEntry(RT_RCDATA, 'FORTYTWO', $0809);
  ...
end;

EntryExists can also be used to perform partial checks for entries. It can omit the name and / or the language id when searching for resources. You can take advantage of this behaviour to get some useful information about the resource file. Examples are:

Links: