本人初学Delphi,很多东西不懂,请各位给出代码的时候完全一点我要实现在.net和delphi之间传数据,.net调用Zlib.dll压缩解压缩byte数组已经实现了,现在要在delphi中实现。Unit UCompressinterface
Uses Classes,SysUtils,ZLib,ZLibConst;
type
TBytes = array of Byte;
function CompressBytes(ASrcBytes: TBytes): TBytes;
function DecompressBytes(ASrcBytes: TBytes;): TBytes;implementationend.谁能给出这2个函数的实现代码,百分相送,最好实现在压缩后的数组前4或8个元素保存原始数据大小
Uses Classes,SysUtils,ZLib,ZLibConst;
type
TBytes = array of Byte;
function CompressBytes(ASrcBytes: TBytes): TBytes;
function DecompressBytes(ASrcBytes: TBytes;): TBytes;implementationend.谁能给出这2个函数的实现代码,百分相送,最好实现在压缩后的数组前4或8个元素保存原始数据大小
解决方案 »
- 皮肤控件中的SkinData是什么作用?
- 谁知道如何用indy控件发送html格式的邮件?……………………………………在线等!!
- open存储过程时,出现EDBEngineError,Invalid Parameter错误,急!
- 请教:急!!!调用其他语言写的dll function unsigned shot WINAPI test(int cs,unsigned char *out)
- ¥¥¥¥¥¥ 200分 请大家讨论! ¥¥¥¥¥
- Ado操作?
- 各位高手!监控键盘可以不用Dll就能做全局钩子。不知道监控鼠标能不能也不放在Dll里面!
- 欢迎光临!!!!!!!!!!!
- 用Indy的TidSmtp与TidMessage这两个控件,怎么发送带有附件的Html邮件?
- 请教高手:关于加密数据存入MDB数据库问题---急!急!急!
- 再问对象释放问题
- 则怎样把程序窗口最大化
var
ZlibCompressor: TCompressionStream;
ZipCount: LongWord;
DestStream:TMemoryStream;
begin
DestStream:=TMemoryStream.Create;
ZipCount:=length(ASrcBytes);
DestStream.Write(ZipCount, SizeOf(LongWord));
ZlibCompressor:=TCompressionStream.Create(clDefault, DestStream);
try
ZlibCompressor.Write(ASrcBytes[0], length(ASrcBytes));
finally
FreeAndNil(ZlibCompressor); ;
end;
DestStream.Seek(0, 0);
SetLength(Result,DestStream.Size);
DestStream.Read(Result[0],DestStream.Size);
DestStream.Free;
end;
function DecompressBytes(ASrcBytes: TBytes): TBytes;
var
UnZipStream : TDecompressionStream;
UnZipCount:LongWord;
SourseStream:TMemoryStream;
begin
SourseStream:=TMemoryStream.Create; SourseStream.Write(ASrcBytes[0],length(ASrcBytes));
SourseStream.Seek(0,0);
SourseStream.Read(UnZipCount,SizeOf(LongWord)); UnZipStream := TDecompressionStream.Create(SourseStream);
try
SetLength(Result,UnZipCount);
UnZipStream.Read(Result[0],UnZipCount);
finally
UnZipStream.Free;
end;
end;