Hi, i've compressed a file using Microsoft's Compress.exe utility, and i can't decompress it with lzexpand.dll :/
LZOpenFile returns a valid handle (value greater than 0)
LZSeek(myhandle, 0, 2) seeks to the end of the compressed file (in opposition to what is said in platform sdk; it should seek to the end of uncompressed file).
LZRead fails with -3 (LZERROR_READ ).
any ideas how to decompress a file with lzexpand.dll ?
LZOpenFile returns a valid handle (value greater than 0)
LZSeek(myhandle, 0, 2) seeks to the end of the compressed file (in opposition to what is said in platform sdk; it should seek to the end of uncompressed file).
LZRead fails with -3 (LZERROR_READ ).
any ideas how to decompress a file with lzexpand.dll ?
Here's the complete app demonstrating how to use lzexpand.dll to decompress lz-compressed files. decompressing into memory is not supported. You can only "copy" the contents of a compressed file to a decompressed one.
Note: While compressing with Microsoft's compress.exe, you have to use the default "lz" method (not the "ms" one).
// attempts to decompress an LZ-compressed file
#define UNICODE
#define WIN32_LEAN_AND_MEAN
#include <windows.h>
#include <Lzexpand.h>
#include <stdio.h>
TCHAR inbuf[512], outbuf[512]; // Buffers for filenames.
OFSTRUCT ofs1, ofs2; // OpenFile structures. Required by LZ- functions.
TCHAR iname[] = L"Input filename: ",
oname[] = L"Output filename: ",
sfmt1[] = L"%s";
INT main (INT argc, BYTE *argv[]) {
INT rtval, rtval2;
// prepare to decompress
wprintf(sfmt1, iname);
wscanf(sfmt1, inbuf);
wprintf(sfmt1, oname);
wscanf(sfmt1, outbuf);
outbuf[511] = inbuf[511] = 0;
// do the decompression. Write decompressed input file to the beginning of the output file.
// file to memory, or memory to memory decompression seems not to be supported.
rtval = LZOpenFile(inbuf, &ofs1, OF_PROMPT | OF_READ | OF_SHARE_DENY_WRITE);
if ((rtval > -1) || (rtval < -8)) { // error check
rtval2 = LZOpenFile(outbuf, &ofs2, OF_WRITE | OF_SHARE_EXCLUSIVE | OF_CREATE);
if ((rtval2 > -1) || (rtval2 < -8)) { // error check
LZCopy(rtval, rtval2);
LZClose(rtval2);
}
LZClose(rtval);
rtval = ERROR_SUCCESS;
}
else rtval = ERROR_FILE_NOT_FOUND;
return rtval;
}
Note: While compressing with Microsoft's compress.exe, you have to use the default "lz" method (not the "ms" one).