再问关于zlib.dll的问题

woshialber 2006-06-22 03:24:53
我在这篇帖子里问了关于zlib.dll的一些问题
http://community.csdn.net/Expert/TopicView3.asp?id=4743644
很多问题得到了解决,非常感谢jjwwang(风归叶) 和 pp616(傻小子)

现在还有些问题无法得到解决,
1.不知道怎么直接使用zlib.dll,谁能给我给例子?(官方网站上好像也没有例子)
2.我安装了delphi的zlib.pas控件,用TCompressionStream 压缩的文件竟然用WinRar程序打不开?
用 TDecompressionStream解压文件时在执行CCheck函数时有错误,不知道是为什么?


希望大虾们能多多指点一下,谢谢!
...全文
733 点赞 收藏 11
写回复
11 条回复
切换为时间正序
当前发帖距今超过3年,不再开放新的回复
发表回复
laowang2 2006-11-29
mark
回复
CityHost 2006-06-26
来学习,做个收藏
回复
亮灯了 2006-06-22
关注!
回复
woshialber 2006-06-22
还是这个好用阿
http://codeproject.com/file/zip_utils.asp
其实我也下过,不过没有仔细研究
今天研究了一下,发现很好用,赫赫!
回复
CACACACACA 2006-06-22
/* zconf.h -- configuration of the zlib compression library
* Copyright (C) 1995-1996 Jean-loup Gailly.
* For conditions of distribution and use, see copyright notice in zlib.h
*/

/* $Id: zconf.h,v 1.20 1996/07/02 15:09:28 me Exp $ */

#ifndef _ZCONF_H
#define _ZCONF_H

/*
* If you *really* need a unique prefix for all types and library functions,
* compile with -DZ_PREFIX. The "standard" zlib should be compiled without it.
*/
#ifdef Z_PREFIX
# define deflateInit_ z_deflateInit_
# define deflate z_deflate
# define deflateEnd z_deflateEnd
# define inflateInit_ z_inflateInit_
# define inflate z_inflate
# define inflateEnd z_inflateEnd
# define deflateInit2_ z_deflateInit2_
# define deflateSetDictionary z_deflateSetDictionary
# define deflateCopy z_deflateCopy
# define deflateReset z_deflateReset
# define deflateParams z_deflateParams
# define inflateInit2_ z_inflateInit2_
# define inflateSetDictionary z_inflateSetDictionary
# define inflateSync z_inflateSync
# define inflateReset z_inflateReset
# define compress z_compress
# define uncompress z_uncompress
# define adler32 z_adler32
# define crc32 z_crc32
# define get_crc_table z_get_crc_table

# define Byte z_Byte
# define uInt z_uInt
# define uLong z_uLong
# define Bytef z_Bytef
# define charf z_charf
# define intf z_intf
# define uIntf z_uIntf
# define uLongf z_uLongf
# define voidpf z_voidpf
# define voidp z_voidp
#endif

#if (defined(_WIN32) || defined(__WIN32__)) && !defined(WIN32)
# define WIN32
#endif
#if defined(__GNUC__) || defined(WIN32) || defined(__386__) || defined(i386)
# ifndef __32BIT__
# define __32BIT__
# endif
#endif
#if defined(__MSDOS__) && !defined(MSDOS)
# define MSDOS
#endif

/*
* Compile with -DMAXSEG_64K if the alloc function cannot allocate more
* than 64k bytes at a time (needed on systems with 16-bit int).
*/
#if defined(MSDOS) && !defined(__32BIT__)
# define MAXSEG_64K
#endif
#ifdef MSDOS
# define UNALIGNED_OK
#endif

#if (defined(MSDOS) || defined(_WINDOWS) || defined(WIN32)) && !defined(STDC)
# define STDC
#endif
#if (defined(__STDC__) || defined(__cplusplus)) && !defined(STDC)
# define STDC
#endif

#ifndef STDC
# ifndef const /* cannot use !defined(STDC) && !defined(const) on Mac */
# define const
# endif
#endif

/* Some Mac compilers merge all .h files incorrectly: */
#if defined(__MWERKS__) || defined(applec) ||defined(THINK_C) ||defined(__SC__)
# define NO_DUMMY_DECL
#endif

/* Maximum value for memLevel in deflateInit2 */
#ifndef MAX_MEM_LEVEL
# ifdef MAXSEG_64K
# define MAX_MEM_LEVEL 8
# else
# define MAX_MEM_LEVEL 9
# endif
#endif

/* Maximum value for windowBits in deflateInit2 and inflateInit2 */
#ifndef MAX_WBITS
# define MAX_WBITS 15 /* 32K LZ77 window */
#endif

/* The memory requirements for deflate are (in bytes):
1 << (windowBits+2) + 1 << (memLevel+9)
that is: 128K for windowBits=15 + 128K for memLevel = 8 (default values)
plus a few kilobytes for small objects. For example, if you want to reduce
the default memory requirements from 256K to 128K, compile with
make CFLAGS="-O -DMAX_WBITS=14 -DMAX_MEM_LEVEL=7"
Of course this will generally degrade compression (there's no free lunch).

The memory requirements for inflate are (in bytes) 1 << windowBits
that is, 32K for windowBits=15 (default value) plus a few kilobytes
for small objects.
*/

/* Type declarations */

#ifndef OF /* function prototypes */
# ifdef STDC
# define OF(args) args
# else
# define OF(args) ()
# endif
#endif

/* The following definitions for FAR are needed only for MSDOS mixed
* model programming (small or medium model with some far allocations).
* This was tested only with MSC; for other MSDOS compilers you may have
* to define NO_MEMCPY in zutil.h. If you don't need the mixed model,
* just define FAR to be empty.
*/
#if (defined(M_I86SM) || defined(M_I86MM)) && !defined(__32BIT__)
/* MSC small or medium model */
# define SMALL_MEDIUM
# ifdef _MSC_VER
# define FAR __far
# else
# define FAR far
# endif
#endif
#if defined(__BORLANDC__) && (defined(__SMALL__) || defined(__MEDIUM__))
# ifndef __32BIT__
# define SMALL_MEDIUM
# define FAR __far
# endif
#endif
#ifndef FAR
# define FAR
#endif

typedef unsigned char Byte; /* 8 bits */
typedef unsigned int uInt; /* 16 bits or more */
typedef unsigned long uLong; /* 32 bits or more */

#if defined(__BORLANDC__) && defined(SMALL_MEDIUM)
/* Borland C/C++ ignores FAR inside typedef */
# define Bytef Byte FAR
#else
typedef Byte FAR Bytef;
#endif
typedef char FAR charf;
typedef int FAR intf;
typedef uInt FAR uIntf;
typedef uLong FAR uLongf;

#ifdef STDC
typedef void FAR *voidpf;
typedef void *voidp;
#else
typedef Byte FAR *voidpf;
typedef Byte *voidp;
#endif


/* Compile with -DZLIB_DLL for Windows DLL support */
#if (defined(_WINDOWS) || defined(WINDOWS)) && defined(ZLIB_DLL)
# include <windows.h>
# define EXPORT WINAPI
#else
# define EXPORT
#endif

#endif /* _ZCONF_H */
回复
woshialber 2006-06-22
to unsigned:
zlib.dll的调用在官网上的什么位置?我没有找到:(
用delphi的我安装了delphi的zlib.pas控件,怎样设置标准格式?
回复
woshialber 2006-06-22
to jjwwang(风归叶):
不好意思,我还少个zconf.h的头文件,能贴一下吗?
谢谢。
还有你给的例子用什么头文件?
fstream?
回复
3996906 2006-06-22
有dll为什么不早说呢。。害俺用啥obj。。。。
回复
僵哥 2006-06-22
zlib.dll的调用在官网上有C/C++/VC++的版本,BCB与之相同
zlib由于默认没有特殊标准,仅只是压缩流,所以在未经处理的情况下任何工具都不会认识。
如果需要使用winrar打开,建立 楼主使用通用的zip格式
http://codeproject.com/file/zip_utils.asp
回复
BlueDeepOcean 2006-06-22
一般对DLL的调用如下:

typedef void __stdcall (*DLL中包含的函数名)(如果有参数,写下参数类型);
HMODULE hModule = LoadLibrary(DLL所在路径及文件名);
if (hModule)
{
DLL中包含的函数名 函数变量 = (DLL中包含的函数名)GetProcAddress(hModule,"DLL中包含的函数名");
函数变量(如果有参数,写下参数类型对应的变量);
}
回复
CACACACACA 2006-06-22
void test_compress_filter()
{
boost::iostreams::filtering_ostream out;
boost::iostreams::file_sink of("c:\\out.z" , ios:ut | ios::binary);
out.push(boost::iostreams::zlib_compressor());
out.push(of);

FILE* ifile = NULL;
ifile = fopen("c:\\a.bmp", "rb";
if (ifile != NULL) {
char buf[8192];
while (!feof(ifile)) {
memset(buf,0,8192);
int read = fread(buf,1,8192,ifile);
out.write(buf, read);
}
fclose(ifile);
}
out.flush();
out.set_auto_close(true);
}

void test_uncompress_filter()
{
boost::iostreams::filtering_istream in;
boost::iostreams::file_source file("c:\\out.z", ios::in | ios::binary);
in.push(boost::iostreams::zlib_decompressor());
in.push(file);


FILE* ofile = NULL;
int i;
char buf[8192];
int gc = 0;
ofile = fopen("c:\\b.bmp","wb";
if (ofile != NULL) {
do {
memset(buf, 0, 8192);
in.read(buf, 8192);
gc = in.gcount();
cout << gc << endl;
fwrite(buf,1, gc,ofile);

} while(gc > 0 && in.good());

fclose(ofile);
}
}
回复
相关推荐
发帖
C++ Builder
创建于2007-08-02

1.3w+

社区成员

C++ Builder相关内容讨论区
申请成为版主
帖子事件
创建了帖子
2006-06-22 03:24
社区公告
暂无公告