您现在的位置:首页 >> 网络通讯 >> 网络通讯 >> 内容

Delphi查看WebBrowser提交之前的数据头

时间:2011/9/3 15:12:32 点击:

  核心提示:procedure TPostForm.WebBrowser1BeforeNavigate2(ASender: TObject; const pDisp: IDispatch; var URL, Fl...
procedure TPostForm.WebBrowser1BeforeNavigate2(ASender: TObject; const pDisp: IDispatch; var URL, Flags, TargetFrameName, PostData, Headers: OleVariant; var Cancel: WordBool) ;
  function OleVariantToMemoryStream(OV: OleVariant): TMemoryStream;
  var
    Data: PByteArray;
    Size: integer;
  begin
    Result := TMemoryStream.Create;
    try
       Size := VarArrayHighBound (OV, 1) - VarArrayLowBound(OV, 1) + 1;
       Data := VarArrayLock(OV) ;
       try
         Result.Position := 0;
         Result.WriteBuffer(Data^, Size) ;
       finally
         VarArrayUnlock(OV) ;
       end;
    except
       Result.Free;
       Result := nil;
    end;
  end;
var
  ms: TMemoryStream;
  ss: TStringStream;
begin
  ss := TStringStream.Create('') ;
  try
    if Length(PostData) > 0 then
    begin
      ms := OleVariantToMemoryStream(PostData) ;
      ms.Position := 0;
      ss.CopyFrom(ms, ms.size) ;
      ss.Position := 0;
      ShowMessage('HEADER:' + Headers + #13#10#13#10 + ss.DataString) ;
    end;
  finally
    ss.Free;
  end;
end;

作者:站长 来源:转载
共有评论 0相关评论
发表我的评论
  • 大名:
  • 内容:
  • 盒子文章(www.2ccc.com) © 2020 版权所有 All Rights Reserved.
  • 沪ICP备05001939号