Delphi can use the XceedZipItems object via the object's Count and Item properties, like this:
Delphi |
Copy Code |
var
dispZipItems : IDispatch; {IDispatch pointer} ZipItems : XceedZipItems; {The collection} ZipItem : XceedZipItem; {One item} ItemIndex : integer; {Index variable} vaIndex : OleVariant; {Index as a variant} ResultCode : XcdError; {To check return value)
begin
{ Make sure to place an Xceed Zip control named 'xZip' on a form, } { as well as a list box named 'Listbox1' }
xZip.License( 'your license key' );
xZip.ZipFilename := 'c:\temp\test.zip'; {The zip file to list}
ResultCode := xZip.GetZipContents(DispZipItems, xcfCollection); {Fill collection}
{Check if it worked successfully} if ResultCode = 0 then begin ZipItems := dispZipItems As XceedZipItems; {Get IXceedZipItems interface}
ItemIndex := 1; {Starting item}
while ItemIndex <= ZipItems.Count do {Loop through items} begin vaIndex := ItemIndex; {Convert to variant} ZipItem := ZipItems.Item[ vaIndex ]; {Get current item} ListBox1.Items.Add(ZipItem.Filename); {Display item name} ItemIndex := ItemIndex + 1; {Go to next item} end; end else ShowMessage ('Unsuccessful. Error # ' + inttostr(ResultCode)); end; |