• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

delphiamf3demo

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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;

  


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
matlab中生成随机数的相关知识发布时间:2022-07-18
下一篇:
MATLAB中产生随机数的那些函数发布时间:2022-07-18
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap