Creating a ZIP file on Windows (XP/2003) in C/C++

前端 未结 7 840
粉色の甜心
粉色の甜心 2020-11-29 05:01

I am looking for a way to create a ZIP file from a folder in Windows C/C++ APIs. I can find the way to do this in VBScript using the Shell32.Application CopyHere method, and

7条回答
  •  时光取名叫无心
    2020-11-29 05:35

    The above code to create an empty zip file is broken, as the comments state, but I was able to get it to work. I opened an empty zip in a hex editor, and noted a few differences. Here is my modified example:

    FILE* f = fopen("path", "wb"); 
    fwrite("\x50\x4B\x05\x06\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00", 22, 1, f);
    fclose(f);
    

    This worked for me. I was able to then open the compressed folder. Not tested with 3rd party apps such as winzip.

提交回复
热议问题