文档详情

在Dephi中使用TStream读写数据的技巧(Techniques for using TStream to read and write data in Dephi).doc

发布:2017-07-21约1.66万字共27页下载文档
文本预览下载声明
在Dephi中使用TStream读写数据的技巧(Techniques for using TStream to read and write data in Dephi) Techniques for using TStream to read and write data in Dephi In Dephi, an abstract data type, TStream, is provided to support the operation of convective data. These data usually come from files, databases, memory objects, OLE objects, and so on. TStream provides a unified, concise way to read and write data. In general, we dont need to directly use the TStream class, and the read and write of streaming data is encapsulated in the VCL control method. However, if these methods can not meet our requirements, you need to manually control the data read and write. One, TStream commonly used methods and attributes: 1., function, Read (VaR Buffer; Count: Longint): Longint; virtual; abstract 2., function, Write (const Buffer; Count: Longint): Longint; virtual; abstract; 3., function, Seek (Offset: Longint; Origin: Word): Longint; virtual; abstract; 4. property Position: Longint; 5. property Size: Longint Read, Write, and Seek are purely virtual functions that provide abstract methods for data reading, writing, and positioning. The Read method reads data from the Stream to the Buffer buffer, and Write implements the reverse operation, which returns the size of the actual read and write data. Seek provides methods for moving data pointers in Stream. The parameter Origin can take soFromBeginning, soFromCurrent, soFromEnd three values, Offset is the offset, and the return value is the position of the current Stream data pointer. Position represents the location of the data pointer in the Stream. This property is readable and written, and it is actually implemented by calling the Seek method, so its more convenient to use this property when actually used. The Size property indicates the size of the current Stream, which is sometimes read-only for different Stream. Two, Stream data read and write. 1. SaveToStream (Stream: TStream); file:// writes the data in the class to the current location of
显示全部
相似文档