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

前端 未结 7 875
粉色の甜心
粉色の甜心 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:39

    EDIT: This answer is old, but I cannot delete it because it was accepted. See the next one

    https://stackoverflow.com/a/121720/3937

    ----- ORIGINAL ANSWER -----

    There is sample code to do that here

    [EDIT: Link is now broken]

    http://www.eggheadcafe.com/software/aspnet/31056644/using-shfileoperation-to.aspx

    Make sure you read about how to handle monitoring for the thread to complete.

    Edit: From the comments, this code only works on existing zip file, but @Simon provided this code to create a blank zip file

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

提交回复
热议问题