Skip to content

Latest commit

 

History

History
42 lines (34 loc) · 1.28 KB

Example9.md

File metadata and controls

42 lines (34 loc) · 1.28 KB

Example #9: Saving a resource file

Once you have created or modified a resource file object there comes a time when you need to save it somewhere. To do this we simply use the SaveToFile or SaveToStream methods of TPJResourceFile.

The following code shows how to use SaveToFile:

var
  ResFile: TPJResourceFile;
begin
  // Assume ResFile references a valid object
  ...
  // Save the file to 'MyResource.res'
  ResFile.SaveToFile('MyResource.res');
end;

The next code snippet shows how accomplish the same thing using SaveToStream:

var
  ResFile: TPJResourceFile;
  Stream: TStream;
begin
  // Assume ResFile references a valid object
  ...
  Stream := TFileStream.Create('MyResource.res', fmCreate);
  try
    ResFile.SaveToStream(Stream);
  finally
    Stream.Free;
  end;
end;

In real life we would just use the code in the first fragment, but this suffices as an example of using SaveToStream.

Links: