Click here to Skip to main content
15,892,480 members
Articles / Desktop Programming / ATL

SAWZip - zip file manipulation control

Rate me:
Please Sign up or sign in to vote.
4.56/5 (6 votes)
29 Aug 2001 357.5K   5.4K   58  
An ATL based control for reading and writing zip files.
// SAWZip.idl : IDL source for SAWZip.dll
//

// This file will be processed by the MIDL tool to
// produce the type library (SAWZip.tlb) and marshalling code.

import "oaidl.idl";
import "ocidl.idl";

#include "IComCollection.idl"

interface IFile;
interface IFiles;
interface IArchive;

	// Private interfaces
	[
		object,
		uuid(EC6851A0-B032-11d4-BFE2-E69214D70446),
		pointer_default(unique)
	]
	interface IFilesPrivate : IUnknown
	{
		[helpstring("method Read")] HRESULT Read([in] long aFileHandle);
		[helpstring("method Close")] HRESULT Close();
		[helpstring("method Create")] HRESULT Create([in] long aFileHandle);
		[propget, helpstring("property Comment")] HRESULT Comment([out, retval] BSTR *pVal);
		[propput, helpstring("property Comment")] HRESULT Comment([in] BSTR newVal);
	};

	[
		object,
		uuid(EC6851A1-B032-11d4-BFE2-E69214D70446),
		pointer_default(unique)
	]
	interface IFilePrivate : IUnknown
	{
		[helpstring("method Read")] HRESULT Read([in] long aFileHandle, [in] long theBytesBeforeZip, [in] short anIndex);
		[helpstring("method Close")] HRESULT Close();
		[helpstring("method Write")] HRESULT Write([in] long aZipFileHandle, [in] long theBytesBeforeZip, [in] short anIndex);
		[helpstring("method WriteHeader")] HRESULT WriteHeader([out] short *aSize);
		[helpstring("method Remove")] HRESULT Remove([in] VARIANT_BOOL lastFile, [out, retval] long *Removed);
		[helpstring("method ReduceOffset")] HRESULT Shift([in] long Count);
		[propget, helpstring("property FileNameInZip")] HRESULT FileNameInZip([out, retval] BSTR *pVal);
	};

	// public interfaces
	[
		object,
		uuid(8BA2FE8D-8506-11D4-BFE2-CB5FED326646),
		dual,
		helpstring("IArchive Interface"),
		pointer_default(unique)
	]
	interface IArchive : IDispatch
	{
		[id(1), helpstring("Opens a Zipfile")] HRESULT Open([in] BSTR aName);
		[id(2), helpstring("method Create")] HRESULT Create([in] BSTR aName);
		[propget, id(3), helpstring("Name of the zipfile")] HRESULT Name([out, retval] BSTR *pVal);
		[propget, id(4), helpstring("property Files")] HRESULT Files([out, retval] IFiles **pVal);
		[id(5), helpstring("method Close")] HRESULT Close();
		[propget, id(6), helpstring("property Comment")] HRESULT Comment([out, retval] BSTR *pVal);
		[propput, id(6), helpstring("property Comment")] HRESULT Comment([in] BSTR newVal);
	};
	[
		object,
		uuid(8BA2FE8F-8506-11D4-BFE2-CB5FED326646),
		dual,
		helpstring("IFiles Interface"),
		pointer_default(unique)
	]
	interface IFiles : IDispatch
	{
		DECLARE_COM_COLLECTION(IFile)
		[id(6), helpstring("method AddFileByName")] HRESULT AddFileByName([in] BSTR fileName, [in] short level, [in] VARIANT_BOOL fullPath, [in] VARIANT_BOOL refresh);
	};
	[
		object,
		uuid(8BA2FE91-8506-11D4-BFE2-CB5FED326646),
		dual,
		helpstring("IFile Interface"),
		pointer_default(unique)
	]
	interface IFile : IDispatch
	{
		[propget, id(1), helpstring("property Name")] HRESULT Name([out, retval] BSTR *pVal);
		[propput, id(1), helpstring("property Name")] HRESULT Name([in] BSTR pVal);
		[id(2), helpstring("method Extract")] HRESULT Extract([in] BSTR aPath, [out, retval] BSTR *pFileName);
		[propget, id(3), helpstring("property Directory")] HRESULT Directory([out, retval] VARIANT_BOOL *pVal);
		[propget, id(4), helpstring("property CompressedSize")] HRESULT CompressedSize([out, retval] long *pVal);
		[propget, id(5), helpstring("property UncompressedSize")] HRESULT UncompressedSize([out, retval] long *pVal);
		[propget, id(6), helpstring("property Level")] HRESULT Level([out, retval] short *pVal);
		[propput, id(6), helpstring("property Level")] HRESULT Level([in] short newVal);
		[propget, id(7), helpstring("property IsDirectory")] HRESULT IsDirectory([out, retval] VARIANT_BOOL *pVal);
		[propget, id(8), helpstring("property Crc32")] HRESULT Crc32([out, retval] long *pVal);
		[propget, id(9), helpstring("property Comment")] HRESULT Comment([out, retval] BSTR *pVal);
		[propput, id(9), helpstring("property Comment")] HRESULT Comment([in] BSTR pVal);
		[propget, id(10), helpstring("property FullPath")] HRESULT FullPath([out, retval] VARIANT_BOOL *pVal);
		[propput, id(10), helpstring("property FullPath")] HRESULT FullPath([in] VARIANT_BOOL newVal);
		[propget, id(11), helpstring("property Index")] HRESULT Index([out, retval] short *pVal);
		[id(12), helpstring("method ExtractToString")] HRESULT ExtractToString([out, retval] BSTR *strResult);
		[id(13), helpstring("method ExtractToStream")] HRESULT ExtractToStream([in] IStream *aStream);
		[propget, id(14), helpstring("property ModificationDate")] HRESULT ModificationDate([out, retval] DATE *pVal);
		[propput, id(14), helpstring("property ModificationDate")] HRESULT ModificationDate([in] DATE newVal);
	};

[
	uuid(8BA2FE81-8506-11D4-BFE2-CB5FED326646),
	version(1.0),
	helpstring("SAWZip 1.0 Type Library")
]
library SAWZIPLib
{
	importlib("stdole32.tlb");
	importlib("stdole2.tlb");

	[
		uuid(8BA2FE8E-8506-11D4-BFE2-CB5FED326646),
		helpstring("Archive Class")
	]
	coclass Archive
	{
		[default] interface IArchive;
	};
	[
		uuid(8BA2FE90-8506-11D4-BFE2-CB5FED326646),
		helpstring("Files Class"),
		noncreatable
	]
	coclass Files
	{
		[default] interface IFiles;
	};
	[
		uuid(8BA2FE92-8506-11D4-BFE2-CB5FED326646),
		helpstring("File Class")
	]
	coclass File
	{
		[default] interface IFile;
	};
};

By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.

If a file you wish to view isn't highlighted, and is a text file (not binary), please let us know and we'll add colourisation support for it.

License

This article has no explicit license attached to it but may contain usage terms in the article text or the download files themselves. If in doubt please contact the author via the discussion board below.

A list of licenses authors might use can be found here


Written By
Web Developer
Belgium Belgium
Programmer since 1991 using C/C++/Visual Basic and Java. Playing with wxWindows at home.

Comments and Discussions