在线时间:8:00-16:00
迪恩网络APP
随时随地掌握行业动态
扫描二维码
关注迪恩网络微信公众号
delphi amf3 demo procedure TForm1.Button1Click(Sender: TObject); //还原 var buff: array of Byte; bufflen, I: Integer; hex: string; XXX: variant; begin hex := Trim(Memo1.Lines.Text); bufflen := Length(hex) div 2; SetLength(buff, bufflen); for I := 0 to bufflen - 1 do begin buff[I] := StrToInt('$' + hex[1 + I * 2] + hex[2 + I * 2]); end; QAMF3Helpher.SetData(@buff[0], bufflen); XXX := QAMF3Helpher.ReadAMF3Variant; Memo2.Text := XXX; end; procedure TForm1.Button2Click(Sender: TObject); //序列字符串 var I: Integer; tmp: string; tmpAdd: DWORD; begin QAMF3Helpher.BeforeWrite; QAMF3Helpher.WriteAMF3Variant('你好,QAMF3'); tmp := ''; tmpAdd := DWORD(QAMF3Helpher.Stream.Memory); for I := 0 to QAMF3Helpher.Stream.Size do begin tmp := tmp + inttohex(pbyte(tmpAdd + I)^, 2); end; Memo1.Lines.Text := tmp; //061DE4BDA0E5A5BDEFBC8C51414D463300 end; procedure TForm1.Button3Click(Sender: TObject); //序列小数 var I: Integer; tmp: string; tmpAdd: DWORD; begin QAMF3Helpher.BeforeWrite; QAMF3Helpher.WriteAMF3Variant(22.0); tmp := ''; tmpAdd := DWORD(QAMF3Helpher.Stream.Memory); for I := 0 to QAMF3Helpher.Stream.Size do begin tmp := tmp + inttohex(pbyte(tmpAdd + I)^, 2); end; Memo1.Lines.Text := tmp; //05403600000000000000 end; procedure TForm1.Button4Click(Sender: TObject); //序列时间 var I: Integer; tmp: string; tmpAdd: DWORD; begin QAMF3Helpher.BeforeWrite; QAMF3Helpher.WriteAMF3Variant(Now()); tmp := ''; tmpAdd := DWORD(QAMF3Helpher.Stream.Memory); for I := 0 to QAMF3Helpher.Stream.Size do begin tmp := tmp + inttohex(pbyte(tmpAdd + I)^, 2); end; Memo1.Lines.Text := tmp; //0801427759CEABD5900000 end; procedure TForm1.Button5Click(Sender: TObject); //序列结构体 var ioResponse: IAS3Object; ioResponseHeader: IAS3Object; I: Integer; tmp: string; tmpAdd: DWORD; begin QAMF3Helpher.BeforeWrite; ioResponse := TAS3Object.Create; ioResponseHeader := TAS3Object.Create; ioResponse.SetAS3ClassName('TESTResponse'); ioResponse.SetIsDynamic(false); ioResponse.SetIsExternalized(false); ioResponseHeader.SetAS3ClassName('TESTResponseHeader'); ioResponseHeader.SetIsDynamic(false); ioResponseHeader.SetIsExternalized(false); ioResponseHeader.SetValue('StatusCode', 0); ioResponseHeader.SetValue('StatusText', '测试状态'); ioResponseHeader.SetValue('InternalStatusCode', 255); ioResponse.SetValue('header', ioResponseHeader); QAMF3Helpher.WriteAMF3Type(amf3dtObject); QAMF3Helpher.WriteAMF3Object(ioResponse); tmp := ''; tmpAdd := DWORD(QAMF3Helpher.Stream.Memory); for I := 0 to QAMF3Helpher.Stream.Size do begin tmp := tmp + inttohex(pbyte(tmpAdd + I)^, 2); end; Memo1.Lines.Text := tmp; //0A131954455354526573706F6E73650D6865616465720A332554455354526573706F6E736548656164657215537461747573436F6465155374617475735465787425496E7465726E616C537461747573436F646504000619E6B58BE8AF95E78AB6E6808104817F00 end; procedure TForm1.Button6Click(Sender: TObject); var S: AnsiString; begin // S := #$0a#$00#$00 + #$00#$01#$11#$0a#$0b#$0d#$6d#$79#$54#$79#$70#$65#$11#$61#$72#$72 + #$61#$79#$56#$61#$6c#$09#$07#$01#$04#$01#$04#$02#$06#$07#$65#$72 + #$74#$13#$73#$74#$72#$69#$6e#$67#$56#$61#$6c#$06#$07#$62#$6c#$61 + #$0d#$69#$6e#$74#$56#$61#$6c#$04#$02#$01; QAMF3Helpher.SetData(PAnsiChar(S),Length(S)); QAMF3Helpher.ReadAMF0Type; QAMF3Helpher.ReadAMF0Array; // end; procedure TForm1.FormClose(Sender: TObject; var Action: TCloseAction); begin QAMF3Helpher.Free; end; procedure TForm1.FormCreate(Sender: TObject); begin QAMF3Helpher := TQAMF3Helpher.Create; end;
|
2023-10-27
2022-08-15
2022-08-17
2022-09-23
2022-08-13
请发表评论