Click here to Skip to main content
15,891,607 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi All,

I have a piece of code to unzip files, but I need to get the list of the files I am unzipping. I use the shell32 APIs by importing shell32.dll, I am pasting the code below for everyone else to have a look, I tried to iterate through the Shell32::FolderItemsPtr to get the file list , but this did not work. Please could some body offer me a viable solution.

bool doUnZip( const char* src, const char* dest )
{
    CoInitialize(0); 
    Shell32::IShellDispatch2Ptr shell;
    shell.CreateInstance(__uuidof(Shell32::Shell));
    _bstr_t bs( src );
    _variant_t varsrc ( bs );
    Shell32::FolderPtr srcfolder = shell->NameSpace( varsrc );

    _bstr_t bd( dest );
    _variant_t vardest( bd );
    Shell32::FolderPtr destfolder = shell->NameSpace( vardest );
    Shell32::FolderItemsPtr items = srcfolder->Items();
    
    long flags = FOF_NOCONFIRMATION | FOF_NOERRORUI;
    HRESULT hres = destfolder->CopyHere( 
	_variant_t((IDispatch*)items,true), flags );
    ::Sleep(1000);
    CoUninitialize(); 
    if ( SUCCEEDED(hres) )
	return true;
    else
    {
	const char* errmsg = "Unzip Failed";
	return false;
    }
}


Thanks to All in advance
Ranojay
Posted
Comments
Lakamraju Raghuram 25-Jan-12 1:16am    
Have tried unzipping by this util:
http://www.codeproject.com/Articles/7530/Zip-Utils-clean-elegant-simple-C-Win32

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900