想写个程序,调用zlib1.dll压缩解压文件,但是老是弹出这个错误。不知道是dll本身的问题还是怎么回事?请高手解答,先说声谢谢,由于我是第一次提问,貌似没什么分送。源代码如下:implementation{$R *.dfm}function compress(infile:pointer;infilesize:integer;outfile:pointer;outfilesize:integer):integer;stdcall;external 'zlib1.dll';
function decompress(infile:pointer;infilesize:integer;ourfile:pointer;ourfilesize:integer):integer;stdcall;external 'zlib1.dll';
procedure TForm1.ButtoncompressClick(Sender: TObject);
var
filehandle:integer;
filelen:integer;
buffer:pchar;
outfile:pchar;
outfilelen:integer;
begin
if opendialog1.Execute then
begin
filehandle := fileopen(opendialog1.filename,fmopenread);
filelen := fileseek(filehandle,0,2);
fileseek(filehandle,0,0);
buffer := pchar(allocmem(filelen+1));
fileread(filehandle,buffer^,filelen);
fileclose(filehandle);
outfile := pchar(allocmem(filelen*4));
outfilelen := filelen*2;
compress(outfile,outfilelen,buffer,filelen);
end;
else
end;
end.
function decompress(infile:pointer;infilesize:integer;ourfile:pointer;ourfilesize:integer):integer;stdcall;external 'zlib1.dll';
procedure TForm1.ButtoncompressClick(Sender: TObject);
var
filehandle:integer;
filelen:integer;
buffer:pchar;
outfile:pchar;
outfilelen:integer;
begin
if opendialog1.Execute then
begin
filehandle := fileopen(opendialog1.filename,fmopenread);
filelen := fileseek(filehandle,0,2);
fileseek(filehandle,0,0);
buffer := pchar(allocmem(filelen+1));
fileread(filehandle,buffer^,filelen);
fileclose(filehandle);
outfile := pchar(allocmem(filelen*4));
outfilelen := filelen*2;
compress(outfile,outfilelen,buffer,filelen);
end;
else
end;
end.
解决方案 »
- 初学delphi 谁能给我一个简单和sql server2005操作的简单例子
- 多文档应用程序,子窗体出现闪动!!!!
- 异地两台通过网关上网的计算机如何建立通讯?
- 放全部身家求助!D版的高手都进来看!别让人说老外能做的东西我们做不了!!
- 在程式保存文件时怎样,把文件的扩展名自动存成文本格式
- F1
- 为何 Findwindow() 在 Win2000 的服务程序中返回值为0?
- 求 如果实现远程数据的采集,50分相送!
- 哪里有VBA編程的書籍可下載?
- 我的难题不断:如何将QuickReport结果页面保存为BMP格式文件?
- excel奇怪的问题
- 求教关于从数据库里调出数据在tchart上划多条线的小问题!!!谢谢大家了
有压缩解压缩的控件啊
挺好用的 还有Demo
int compress (Bytef *dest, uLongf *destLen, const Bytef *source, uLong sourceLen);
Compresses the source buffer into the destination buffer. sourceLen is the byte length of the source buffer. Upon entry, destLen is the total size of the destination buffer, which must be at least 0.1% larger than sourceLen plus 12 bytes. Upon exit, destLen is the actual size of the compressed buffer. This function can be used to compress a whole file at once if the input file is mmap'ed. compress returns Z_OK if success, Z_MEM_ERROR if there was not enough memory, Z_BUF_ERROR if there was not enough room in the output buffer.