首先到www.zlib.net下载个ZLIB,解压缩后打开zlib-1.2.3/projects/visualc6/zlib.dsw
选择Win32 LIB Release 按F7编绎生成zlib.lib
工程中使用时把
D:/zlib-1.2.3/projects/visualc6/Win32_LIB_Release/zlib.lib
D:/zlib-1.2.3/zlib.h
D:/zlib-1.2.3/zconf.h
拷贝到所在工程目录下,然后
#include "zlib.h"
#pragma comment(lib,"zlib.lib")
void CZlibTestDlg::OnButton1()
{
const unsigned char strSrc[]="hello world!/n/
aaaaa bbbbb ccccc ddddd aaaaa bbbbb ccccc ddddd中文测试 中文测试/
aaaaa bbbbb ccccc ddddd aaaaa bbbbb ccccc ddddd中文测试 中文测试/
aaaaa bbbbb ccccc ddddd aaaaa bbbbb ccccc ddddd中文测试 中文测试/
aaaaa bbbbb ccccc ddddd aaaaa bbbbb ccccc ddddd中文测试 中文测试";
unsigned char buff[1024]={0},strDst[1024]={0};
unsigned long srcLen=sizeof(strSrc),bufLen=sizeof(buff),dstLen=sizeof(strDst);
CString strc,strc2,strc3;
strc.Format("Src string:%s/nLength:%d/n===================/n",strSrc,srcLen);
//压缩
compress(buff,&bufLen,strSrc,srcLen);
strc2.Format("/nAfter Compressed Length:%d/nCompressed String:%s/n==============/n",bufLen,buff);
//解压缩
uncompress(strDst,&dstLen,buff,bufLen);
strc3.Format("/nAfter UnCompressed Length:%d/nUnCompressed String:%s/n",dstLen,strDst);
AfxMessageBox(strc+strc2+strc3);
}
选择Win32 LIB Release 按F7编绎生成zlib.lib
工程中使用时把
D:/zlib-1.2.3/projects/visualc6/Win32_LIB_Release/zlib.lib
D:/zlib-1.2.3/zlib.h
D:/zlib-1.2.3/zconf.h
拷贝到所在工程目录下,然后
#include "zlib.h"
#pragma comment(lib,"zlib.lib")
void CZlibTestDlg::OnButton1()
{
const unsigned char strSrc[]="hello world!/n/
aaaaa bbbbb ccccc ddddd aaaaa bbbbb ccccc ddddd中文测试 中文测试/
aaaaa bbbbb ccccc ddddd aaaaa bbbbb ccccc ddddd中文测试 中文测试/
aaaaa bbbbb ccccc ddddd aaaaa bbbbb ccccc ddddd中文测试 中文测试/
aaaaa bbbbb ccccc ddddd aaaaa bbbbb ccccc ddddd中文测试 中文测试";
unsigned char buff[1024]={0},strDst[1024]={0};
unsigned long srcLen=sizeof(strSrc),bufLen=sizeof(buff),dstLen=sizeof(strDst);
CString strc,strc2,strc3;
strc.Format("Src string:%s/nLength:%d/n===================/n",strSrc,srcLen);
//压缩
compress(buff,&bufLen,strSrc,srcLen);
strc2.Format("/nAfter Compressed Length:%d/nCompressed String:%s/n==============/n",bufLen,buff);
//解压缩
uncompress(strDst,&dstLen,buff,bufLen);
strc3.Format("/nAfter UnCompressed Length:%d/nUnCompressed String:%s/n",dstLen,strDst);
AfxMessageBox(strc+strc2+strc3);
}