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);
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¶
| Name | Description |
|---|---|
| TAbstractResource.RawData | The raw resource data stream |