在Windows(XP / 2003)中使用C / C ++创建ZIP文件 [英] Creating a ZIP file on Windows (XP/2003) in C/C++

查看:216
本文介绍了在Windows(XP / 2003)中使用C / C ++创建ZIP文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在寻找一种从Windows C / C ++ API中的文件夹创建ZIP文件的方法。我可以找到方法来做到这一点在VBScript使用Shell32.Application CopyHere方法,我找到一个教程解释如何在C#中做,但没有为C API(C ++也很好,项目已经使用MFC)。

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 I found a tutorial explaining how to do it in C# also, but nothing for the C API (C++ is fine too, project already uses MFC).

如果任何人可以共享一些可以在Windows XP / 2003上成功创建zip文件的示例C代码,我将非常感谢。如果没有,如果有人可以找到固体文档或教程,将是伟大的,因为MSDN搜索不会变得太多。我真的希望避免为此发送第三方库,因为功能显然存在,我只是不知道如何访问它。 Google搜索没有什么有用的,只是诱惑了一些信息。

I'd be really grateful if anyone can share some sample C code that can successfully create a zip file on Windows XP/2003. Failing that, if someone can find solid docs or a tutorial that would be great, since MSDN searches don't turn up much. I'm really hoping to avoid having to ship a third-party lib for this, because the functionality is obviously there, I just can't figure out how to access it. Google searches turn up nothing useful, just tantalizing bits and pieces of information. Here's hoping someone in the community has sorted this out and can share it for posterity!

推荐答案

编辑:这个答案是老的,但是,我无法删除它,因为它被接受。查看下一个

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

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

----- ORIGIN ANSWER -----

----- ORIGIN ANSWER -----

示例代码

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.

编辑:从评论中,此代码仅适用于现有的zip文件,但@ Simon 提供此代码以创建空白zip文件

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("\x80\x75\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);

这篇关于在Windows(XP / 2003)中使用C / C ++创建ZIP文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆