Delphi 2009 中的 Zlib

发布于 2024-07-23 05:58:54 字数 266 浏览 7 评论 0原文

我正在将一个应用程序升级到Delphi 2009。该应用程序使用Soap,我们使用Zlib 压缩soap 请求和响应流。 这在 Delphi 2006 中工作正常,但在 Delphi 2009 中不行。

所以我回到 Delphi 2006 并更改为使用 FastZlib。 它在 Delphi2006 中一切正常,但在 Delphi 2009 中不起作用,并且出现解压缩错误。

有没有其他人有这个问题?

我该如何解决这个问题?

桑迪普

I am upgrading a app to Delphi 2009. The app uses Soap and we compress the soap request and response streams using Zlib. This works fine in Delphi 2006 but not in Delphi 2009.

So I went back to Delphi 2006 and changed to use FastZlib. It all worked fine in Delphi2006 but does not work in Delphi 2009 and I get Decompress errors.

Has anyone else had this problem?

How do I go about fixing this?

Sandeep

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(5

愁以何悠 2024-07-30 05:58:54

在D2009中你可以使用Zcompress/ZDecompress代替CompressBuf/DecompressBuf
我测试了一下,没有问题。

in D2009 you can use ZCompress/ZDecompress instead of CompressBuf/DecompressBuf
I test it and there is no problem.

一枫情书 2024-07-30 05:58:54

我刚刚查看了内置的 Zlib.pas,它似乎已正确更新为 D2009。 是什么给你带来了问题?

I just looked through the built-in Zlib.pas and it appears to have been updated for D2009 properly. What's giving you problems?

泼猴你往哪里跑 2024-07-30 05:58:54

在delphi 2006中,我有以下使用Zlib(来自Delphi 2006)压缩和解压缩的方法,

procedure CompressStream(inpStream, outStream: TStream);
var
  InpBuf, OutBuf: Pointer;
  InpBytes, OutBytes: Integer;
begin
  InpBuf := nil;
  OutBuf := nil;
  try
    GetMem(InpBuf, inpStream.Size);
    inpStream.Position := 0;
    InpBytes := inpStream.Read(InpBuf^, inpStream.Size);
    CompressBuf(InpBuf, InpBytes, OutBuf, OutBytes);
    outStream.Write(OutBuf^, OutBytes);
  finally
    if InpBuf <> nil then FreeMem(InpBuf);
    if OutBuf <> nil then FreeMem(OutBuf);
  end;
end;


{ Decompress a stream }
procedure DecompressStream(inpStream, outStream: TStream);
var
  InpBuf, OutBuf: Pointer;
  OutBytes, sz: Integer;
begin
  InpBuf := nil;
  OutBuf := nil;
  sz     := inpStream.Size - inpStream.Position;
  if sz > 0 then 
    try
      GetMem(InpBuf, sz);
      inpStream.Read(InpBuf^, sz);
      DecompressBuf(InpBuf, sz, 0, OutBuf, OutBytes);
      outStream.Write(OutBuf^, OutBytes);
    finally
      if InpBuf <> nil then FreeMem(InpBuf);
      if OutBuf <> nil then FreeMem(OutBuf);
    end;
  outStream.Position := 0;
end;

我应该更改什么才能使这些方法在Delphi 2009中工作?

In delphi 2006 I had following methods to compress and decompress using Zlib(from Delphi 2006)

procedure CompressStream(inpStream, outStream: TStream);
var
  InpBuf, OutBuf: Pointer;
  InpBytes, OutBytes: Integer;
begin
  InpBuf := nil;
  OutBuf := nil;
  try
    GetMem(InpBuf, inpStream.Size);
    inpStream.Position := 0;
    InpBytes := inpStream.Read(InpBuf^, inpStream.Size);
    CompressBuf(InpBuf, InpBytes, OutBuf, OutBytes);
    outStream.Write(OutBuf^, OutBytes);
  finally
    if InpBuf <> nil then FreeMem(InpBuf);
    if OutBuf <> nil then FreeMem(OutBuf);
  end;
end;


{ Decompress a stream }
procedure DecompressStream(inpStream, outStream: TStream);
var
  InpBuf, OutBuf: Pointer;
  OutBytes, sz: Integer;
begin
  InpBuf := nil;
  OutBuf := nil;
  sz     := inpStream.Size - inpStream.Position;
  if sz > 0 then 
    try
      GetMem(InpBuf, sz);
      inpStream.Read(InpBuf^, sz);
      DecompressBuf(InpBuf, sz, 0, OutBuf, OutBytes);
      outStream.Write(OutBuf^, OutBytes);
    finally
      if InpBuf <> nil then FreeMem(InpBuf);
      if OutBuf <> nil then FreeMem(OutBuf);
    end;
  outStream.Position := 0;
end;

What should I change for these to work in Delphi 2009?

爱*していゐ 2024-07-30 05:58:54

可能值得尝试的事情 - 压缩数据,然后对其进行 UUENCODE,并在另一端反转该过程。 这将检测某些代码是否未正确处理嵌入的零。

抱歉,这只是帮助您缩小问题范围的部分解决方案。

Something that might be worth trying - compress your data, and then UUENCODE it, and on the other end, reverse the process. This will detect if some code is not dealing with embedded zero's properly.

Sorry, this is only a partial solution to help you narrow the problem down.

太阳公公是暖光 2024-07-30 05:58:54

原来的海报很清楚这个问题: CompressBuf 和 DecompressBuf 已经消失了。

我还有一个项目,在 D7 中编译得很好,但在 D2010 中编译失败,因为它找不到“CompressBuf”或“DecompressBuf”。

使用 D7 非常愉快的 find 命令进行搜索,将例程定位在
c:\Program Files\Borland\Delphi7\Source\Rtl\Common\ZLib.pas

但是使用 D2010 的(笨拙的单独)“在文件中查找”命令进行搜索无法在任何地方找到 CompressBuf 或 DecompressBuf。

令人非常不安的是,升级 IDE 会导致项目中使用和需要的例程消失!

The original poster's was clear about the problem: CompressBuf and DecompressBuf are GONE.

I also have a project that compiles just fine in D7, but fails to compile in D2010 because it can't find "CompressBuf" or "DecompressBuf".

A search using D7's very pleasant find command locates the routines at
c:\Program Files\Borland\Delphi7\Source\Rtl\Common\ZLib.pas

But searching with D2010's (awkward separate) "Find in Files" command fails to locate CompressBuf or DecompressBuf anywhere.

It's very disturbing that upgrading the IDE causes routines used and needed in projects to disappear!

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文