[Overview][Resource strings][Constants][Types][Classes][Index] Reference for unit 'resource' (#fcl-res)

TAbstractResource.SetCustomRawDataStream

Sets a custom stream as the underlying stream for RawData

Declaration

Source position: resource.pp line 163

public procedure TAbstractResource.SetCustomRawDataStream(

  aStream: TStream

);

Arguments

aStream

  

The custom stream to use as the underlying RawData stream. It can be nil

Description

Normally, RawData uses a memory stream or the original resource stream (e.g. the original file containing the resource) as its underlying stream. This method allows the user to use a custom stream as the underlying stream. This can be useful when a resource must be created from the contents of an original file as-is.

If aStream is nil, a new memory stream is used as the underlying stream. This can be used to remove a previously set custom stream as the underlying stream.

Sample code

This code creates a resource containing an html file

var
  aType, aName : TResourceDesc;
  aRes : TGenericResource;
  aFile : TFileStream;
begin
  aType:=TResourceDesc.Create(RT_HTML);
  aName:=TResourceDesc.Create('index');
  aRes:=TGenericResource.Create(aType,aName);
  aFile:=TFileStream.Create('index.html',fmOpenRead or fmShareDenyNone);
  aRes.SetCustomRawDataStream(aFile);

  //do something...

  aRes.Free;
  aFile.Free;
  aType.Free;
  aName.Free;
end;

See also

TAbstractResource.RawData

  

The raw resource data stream


Documentation generated on: Sep 28 2017