Unit 'resource' Package
[Overview][Resource strings][Constants][Types][Classes][Index] [#fcl-res]

TAbstractResource.SetCustomRawDataStream

Sets a custom stream as the underlying stream for RawData

Declaration

Source position: resource.pp line 171

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
  Typeame : TResourceDesc;
  aRes : TGenericResource;
  aFile : TFileStream;
begin
  TypeesourceDesc.Create(RT_HTML);
  aName:=TResourceDesc.Create('index');
  aRes:=TGenericResource.Create(Typeme);
  aFile:=TFileStream.Create('index.html',fmOpenRead or fmShareDenyNone);
  aRes.SetCustomRawDataStream(aFile);

  //do something...

  aRes.Free;
  aFile.Free;
  Typee;
  aName.Free;
end;

See also

TAbstractResource.RawData

  

The raw resource data stream


Documentation generated on: Nov 23 2024