Project: Binary Version Information Manipulation Units.
Unit: DelphiDabbler.Lib.VIBin.Resource.
Class: TVIBinResource
Applies to: ~>1.0
procedure WriteToStream(const Stream: IStream);
Writes the binary representation of the version information to a stream.
Parameter:
Exception:
Say you have a Unicode TVIBinResource object containing version information data that you want to write to a file. This can be achieved as follows:
The following code does the job
begin
var VI: TVIBinResource.Create(vrtUnicode);
try
// ...
// Add some data to VI here
// ...
var FS := TFileStream.Create('C:\MyFile', fmCreate);
var FSA: IStream := TStreamAdapter.Create(FS, soOwned);
VI.WriteToStream(FSA);
finally
VI.Free;
end;
end;
Note that we pass ownership of file stream FS to the TStreamAdapter instance FSA, which means that FS will be freed when FSA is destroyed. FSA will be destroyed automatically when it goes out of scope.
For brevity, the TFileStream instance and its IStream wrapper could be created on the fly as follows:
VI.WriteToStream(
TStreamAdapter.Create(
TFileStream.Create('C:\MyFile', fmCreate),
soOwned
)
);