用TmpStr[1]是因为DELPHI字符串类型的原因,因为长字符串中,TmpStr是代表的字符串存储的地址,而TmpStr[1]就是字符串第一个字符的位置,我是这么理解的。所以要用TmpStr[1]。
delphi的帮助中对TmemoryStream的write方法是这样描述的:
Writes Count bytes from Buffer to the current position in the memory buffer and updates the current position by Count bytes.
Delphi syntax:
function Write(const Buffer; Count: Longint): Longint; override;
C++ syntax:
virtual int __fastcall Write(const void *Buffer, int Count);
Description
Use Write to insert Count bytes into the memory buffer of the memory stream, starting at the current position. Write will increase the size of the memory buffer, if necessary, to accommodate the data being written in. If the current position is not the end of the memory buffer, Write will overwrite the data following the current position.
Write updates the Size property to Position + Count, and sets the Position property to the new value of Size. Thus, any data that was stored in the memory stream in the Count bytes after the current position is lost when calling Write.
Write always writes the Count bytes in the Buffer, unless there is a memory failure. Thus, for TMemoryStream, Write is equivalent to the WriteBuffer method.
All other data-writing methods of a memory stream (WriteBuffer, WriteComponent) call Write to do the actual writing.
---------------------
MyStream.Write(TmpStr[1],Length(edit2.text)) 是把TmpStr串中的内容写到MyStream内存流里面,Length(edit2.text)是写入的字符数