Visual C++ can use the XceedZipItems object via the object's Count and Item properties, like this:
VC++ |
Copy Code |
#include "stdafx.h" #include <stdio.h> #import "XceedZip.dll" named_guids no_namespace
int main(int argc, char* argv[]) { CoInitialize( NULL );
try { IXceedZipPtr piXceedZip( CLSID_XceedZip ); piXceedZip->License( _bstr_t( L"your license key ) );
IDispatchPtr pdispItems; // The IDispatch of the collection IXceedZipItemsPtr piFolderItems; // IXceedZipItems of the collection IXceedZipItemPtr piItem; // One item _bstr_t sName; long ResultCode; // Check if successful
piXceedZip->ZipFilename = "c:\\temp\\test.zip"; // Zip file to list
ResultCode = piXceedZip->GetZipContents(&pdispItems, xcfCollection);
if (ResultCode == xerSuccess) { printf( "Successfully obtained the contents of the Zip file.\n");
// Display contents pdispItems->QueryInterface( &piFolderItems );
for( long lIndex = 1; lIndex < piFolderItems->Count; lIndex++ ) { piItem = piFolderItems->Item[ &_variant_t( lIndex ) ]; sName = piItem->GetFilename(); printf( "%S\n", ( const WCHAR* )sName ) } } else { printf("An error occurred while getting the contents.\nDescription: %S\n", piXceedZip->GetErrorDescription(xvtError, ResultCode)); } } catch( const _com_error& xErr ) { printf( "COM error %08x. %S\n", xErr.Error(), ( const char* )xErr.Description() ); } catch( ... ) { printf( "Unexpected error\n" ); }
CoUninitialize(); return 0; } |