摘要: TMsg02 = packed record case _DT: Byte of $01: (_Msg0201: TMsg0201); $02: (_Msg0202: TMsg0202); $03: (_Msg0203: TMsg0203); $04: (_Msg0204: TMsg0204); $05: (_Msg0205: TMsg0205); $06: (_Msg0206: TMsg0206); $07: (_Msg0207: TMsg0207); $08: (_Msg0208: TMsg0208); end;Char($02): case Dt of Char($01): Result 阅读全文
posted @ 2010-09-18 02:13 delphi中间件 阅读(212) 评论(0) 推荐(0) 编辑
摘要: uses Zlib;//压缩函数procedure Zip(var fs: TMemoryStream);var cs: TCompressionStream; ms: TMemoryStream; num: Integer;begin if not(Assigned(fs) and (fs.Size>0)) then Exit; num := fs.Size; ms := TMemoryStream.Create; cs := TCompressionStream.Create(clMax, ms); try fs.SaveToStream(cs); cs.Free; //ms.Pos 阅读全文
posted @ 2010-09-18 01:47 delphi中间件 阅读(194) 评论(0) 推荐(0) 编辑
摘要: //用字符指针读取流中的内容 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 是指针的基准位置, 有三个选值... 阅读全文
posted @ 2010-09-18 01:43 delphi中间件 阅读(225) 评论(0) 推荐(0) 编辑
摘要: 发送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... 阅读全文
posted @ 2010-09-18 01:32 delphi中间件 阅读(305) 评论(0) 推荐(0) 编辑
摘要: 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... 阅读全文
posted @ 2010-09-18 01:19 delphi中间件 阅读(261) 评论(0) 推荐(0) 编辑
摘要: 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... 阅读全文
posted @ 2010-09-18 01:11 delphi中间件 阅读(781) 评论(0) 推荐(1) 编辑
摘要: 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)) 阅读全文
posted @ 2010-09-18 00:53 delphi中间件 阅读(237) 评论(0) 推荐(0) 编辑