摘要:
//用字符指针读取流中的内容 var pc: PChar; begin pc := mStream.Memory;{把字符指针指向内存流} ShowMeage(pc[0]);//从流读入到缓冲区 var buffer: array[0..2] of Char;{定义个字符缓冲区}begin mStream.Seek(0, soFromBegiing); mStream.Read(buffer, SizeOf(buffer)); ShowMeage(buffer);{关于 Seek 函数: 参数1: Offset 是偏移量; 参数2: Origin 是指针的基准位置, 有三个选值... 阅读全文
摘要:
发送try s := 'Hello world!'; stream := TStringStream.Create(s); IdTCPClient1.OpenWriteBuffer; IdTCPClient1.WriteInteger(stream.Size);//注意这里:要先写入流的长度,在读取的时候如果使用 AThread.Connection.ReadStream(stream); IdTCPClient1.WriteStream(stream, true); finally IdTCPClient1.CloseWriteBuffer; st... 阅读全文
摘要:
unit Unit1; interface uses Windows, Meages, SysUtils, Variants, Claes, Graphics, Controls, Forms, Dialogs, StdCtrl type TForm1 = cla(TForm) Memo1: TMemo;{添加 Memo 显示内容}Button1: TButto Button2: TButto procedure Button1Click(Sender: TObject); procedure Button2Click(Sender: TObject); private {Pri... 阅读全文
摘要:
Type TRecord = Record Name: String[10]; address: String[50]; End; TRecordFile = File Of TRecord;Var Form1: TForm1; aRecordFile: TRecordFile; aRecordFileName: String = 'c:PersonS.dat';Implementation{$R *.dfm}Function RecordsSaveToFile(aFileName: String; aRecord: TRecord): Boolean;Begin R... 阅读全文
摘要:
1.服务器端: type TMSG001 = Packed Record //定义记录类型 userId: array[0..19] of char; password: array[0..17] of char; end;PSendMSG=^TMSG001;//定义指针类型var pSend: PSendMSG;//定义指针pSend^.userId := '001';//生成要发送数据pSend^.password := '001';_SocketS.Socket.Connections[i].SendBuf(pSend^, sizeof(TMSG001)) 阅读全文