delphi TMemory Stream 및 TstringStream 변환

4109 단어
 1 procedure TFormTestRichText.btn1Click(Sender: TObject);
 2 begin
 3   //cxrchdt1.Lines.SaveToFile('d:\test.txt');
 4   mStream := TMemoryStream.Create;
 5   cxrchdt1.Lines.SaveToStream(mStream);
 6   ShowMessage(IntToStr(mStream.Size));
 7 end;
 8 
 9 procedure TFormTestRichText.btn2Click(Sender: TObject);
10 var
11   c: Char;
12   s1, s2: string;
13   vMemoryStream: TMemoryStream;
14 begin
15  //cxrchdt1.Lines.LoadFromFile('d:\test.txt');
16   cxrchdt1.Lines.LoadFromStream(mStream);
17 
18   s1 := '';
19   mStream.Position := 0;                       {     }
20   while mStream.Position < mStream.Size do          {    }
21   begin
22     mStream.Read(c, 1);                         {       ,            }
23     s1 := s1 + c + '';                   {     }
24    // s2 := s2 + IntToHex(Byte(c),2) + ' '; {           }
25   end;
26 
27   vMemoryStream := TStringStream.create(s1);
28   cxrchdt1.Lines.LoadFromStream(vMemoryStream);
29 end;

 
전재 대상:https://www.cnblogs.com/yangxuming/p/7573316.html

좋은 웹페이지 즐겨찾기