LZCopy解压函数功能介绍

Windows系统在lz32.dll中提供了解压缩功能,涉及到的函数有

使用范例:

#include <LZExpand.h>
#pragma comment(lib, "lz32.lib")

char* pZipFileName = ".\test.zip";	\\ 原压缩文件
OFSTRUCT ofSrcStruct;
int nSourceFile = LZOpenFile(pZipFileName, &ofSrcStruct, OF_READ);

char* pDestFileName = ".\text.txt"	\\ 目的解压文件
OFSTRUCT ofDescStruct;
int nDestFile = LZOpenFile(pZipFileName, &ofSrcStruct, OF_CREATE);
int iRet = LZCopy(nSourceFile, nDestFile);
if (iRet < 0)
{
	printf("copy file fail. errno:%d \n", iRet);
}
else
{
	printf("copy file size:%d.\n", iRet);
}

该解压功能基本用法如上。该功能的使用有以下注意点:

  • 对压缩文件有要求。

    • 输入的压缩文件必须由微软提供的压缩工具compress.exe来进行压缩,该工具位于windows-resource-kit-tools套件内,该套件的下载地址点此进入
  • 该接口只有解压功能,没有解包功能。

    • 也就是说,它只能单输入、单输出。文档里面虽有提到

    Open the destination files by calling LZOpenFile.

    但从 LZOpenFile 接口上,没找到打开多个目的文件的方法。

该功能在使用起来有上述缺点,不建议使用,如有压缩和解压缩需求,建议直接使用libzib库来做。

posted @ 2021-02-24 14:26  浩天之家  阅读(208)  评论(0编辑  收藏  举报