function TStream
begin
ReadResHeader;
Result := ReadComponent(Instance)
end;
與ReadComponentRes相應的寫方法是WriteComponentRes
⑷ WriteComponent和WriteDescendant方法
Stream對象的WriteDescendant方法在實現過程中
procedure TStream
begin
WriteDescendent(Instance
end;
procedure TStream
var
Writer: TWriter;
begin
Writer := TWriter
try
Writer
finally
Writer
end;
end;
⑸ WriteDescendantRes和WriteComponentRes方法
WriteDescendantRes方法用於將部件寫入Windows資源文件
procedure TStream
TComponent)
begin
WriteDescendentRes(ResName
end;
procedure TStream
Ancestor: TComponent)
var
HeaderSize: Integer;
Origin
Header: array[
begin
Byte((@Header[
Word((@Header[
HeaderSize := StrLen(StrUpper(StrPLCopy(@Header[
Word((@Header[HeaderSize
Longint((@Header[HeaderSize
WriteBuffer(Header
Origin := Position;
WriteDescendent(Instance
ImageSize := Position
Position := Origin
WriteBuffer(ImageSize
Position := Origin + ImageSize;
end;
WriteCompnentRes是與ReadComponentRes相應的對象寫方法
THandleStream對象的行為特別象FileStream對象
THandleStream對象定義了Handle屬性
聲明
Handle屬性提供了對文件句柄的只讀訪問
聲明
Create方法使用傳入的Handle參數創建一個與特定文件句柄相聯的THandleStream對象
這三個方法是TStream的虛方法
THandleStream是從TStream繼承來的
Handle屬性的實現正如Delphi大多數屬性的實現那樣
THandleStream = class(TStream)
private
FHandle: Integer;
public
…
property Handle: Integer read FHandle;
end;
THandleStream的Create方法
constructor THandleStream
begin
FHandle := AHandle;
end;
為實現針對文件的數據對象存儲
Read方法調用FileRead函數實現文件讀操作
function THandleStream
begin
Result := FileRead(FHandle
if Result =
end;
Write方法調用FileWrite函數實現文件寫操作
[
From:http://tw.wingwit.com/Article/program/Delphi/201311/25106.html