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.
Class: TPJResourceFile
Applies to: ~>1.0
class function IsValidResourceStream(const Stm: TStream): Boolean;
This class method checks if a stream contains data representing a valid 32 bit resource file starting at the current position in the stream. This method checks that a 32 bit resource file header is present but does not validate the whole of the file. Note that the stream is not rewound to the starting position after the check is made.
Use IsValidResourceStream to test a stream for validity before loading it into a TPJResourceFile object.
Parameter:
Returns:
True
if the stream contains the required header information or False
if the data is not a valid resource file.
Example:
var
Stm: TStream;
SavedPos: Int64;
RF: TPJResourceFile;
begin
Stm := TFileStream.Create('C:\MyFile.res', fmOpenRead);
try
SavedPos := Stm.Position;
if TPJResourceFile.IsValidResourceStream(Stm) then
begin
RF := TPJResourceFile.Create;
try
Stm.Position := SavedPos;
RF.LoadFromStream(Stm);
// do something with RF here
finally
RF.Free;
end;
end
else
ShowMessage('Stream does not contain valid resource file data');
finally
Stm.Free;
end;
end;