Note that there are some explanatory texts on larger screens.

plurals
  1. POUnclarity about usage of LZ functions
    primarykey
    data
    text
    <p><strong>Note:</strong> this question is about the Windows LZ functions, which are <a href="http://msdn.microsoft.com/en-us/library/windows/desktop/aa364232%28v=vs.85%29.aspx" rel="nofollow">File Management Functions</a> beginning with the prefix LZ: LZOpenFile, LZCopy, LZClose, etc. If Google isn't wrong, these are probably among the most poorly documented functions of the Windows API.</p> <p>I'm trying to figure out what kind of files are actually suited for usage with the Windows LZ functions. The official documentation mentions "data that was compressed using Compress.exe", but the functions are also able to handle uncompressed files, in which case no decompression is applied.</p> <p>Now, when I compress a file with the compress.exe utility from the resource kit (using either the -Z or -ZX switches), and then decompress it using the procedure <a href="http://msdn.microsoft.com/en-us/library/windows/desktop/aa363901%28v=vs.85%29.aspx" rel="nofollow">described here</a>, all I get is the source file unchanged, as if it were not compressed as expected. Even with a compressed file from the original Windows XP setup CD (those named with an underscore at the end in the i386 folder), I get the same result. Conclusion: no matter what file I try to decompress, I get it back unchanged.</p> <p>The code I'm using is pretty straightforward, it basically reproduces the steps described in the MSDN article, so if I have a bug, I guess it must be somewhere else. But I'm still prone to thinking I'm just using the wrong input files. Does anyone have any experience with those LZ functions already? Here's my code in C++.</p> <pre><code>#include &lt;iostream&gt; #include &lt;Windows.h&gt; using namespace std; int main(int argc, char ** argv) { OFSTRUCT ofs1, ofs2; INT hfSrc = -1, hfDest = -1; if (argc &lt;= 2) { cerr &lt;&lt; "Usage: LZTEST Source Destination"; return 1; } __try { hfSrc = LZOpenFile(argv[1], &amp;ofs1, OF_READ); if (hfSrc &lt; 0) { cerr &lt;&lt; "Error invoking LZOpenFile on source file: " &lt;&lt; hfSrc; return 1; } hfDest = LZOpenFile(argv[2], &amp;ofs2, OF_CREATE); if (hfDest &lt; 0) { cerr &lt;&lt; "Error invoking LZOpenFile on destination file: " &lt;&lt; hfDest; return 1; } INT result = LZCopy(hfSrc, hfDest); if (result &lt; 0) { cerr &lt;&lt; "Error invoking LZCopy: " &lt;&lt; result; return 1; } } __finally { if (hfSrc &gt;= 0) LZClose(hfSrc); if (hfDest &gt;= 0) LZClose(hfDest); } cout &lt;&lt; "Success"; return 0; } </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload