Results 1 to 5 of 5

Thread: Zipping & Unzipping Using Shell32.dll

  1. #1

    Thread Starter
    Fanatic Member Emcrank's Avatar
    Join Date
    Jan 2009
    Posts
    566

    Zipping & Unzipping Using Shell32.dll

    Ok i didn't like the idea of having to have a 3rd party application stuck in my apps directory so i asked for help on how to do it with the windows built in Shell32.dll. This is what i found out.
    To use this in your own project you need to make a reference to C:\Windows\System32\shell32.dll
    VB.net Code:
    1. 'Remeber to create a reference to C:\Windows\System32\shell32.dll
    2. 'Project > Add Reference > Browse and then navigate to the Windows\System32\shell32.dll.
    3.     Private Sub ExtractZip(ByVal zipFile As String, ByVal destination As String)
    4.         Dim shell As Shell32.Shell = New Shell32.Shell
    5.         shell.NameSpace(destination).CopyHere(shell.NameSpace(zipFile).Items, Nothing)
    6.         shell = Nothing
    7.     End Sub
    8.  
    9.     Public Sub ZipFile(ByVal strFileToZip, ByVal strTargetZip)
    10.         CreateEmptyZip(strTargetZip)
    11.         Try
    12.             CreateObject("Shell.Application").Namespace(strTargetZip).CopyHere(strFileToZip)
    13.         Catch ex As Exception
    14.  
    15.         End Try
    16.     End Sub
    17.  
    18.     Private Sub CreateEmptyZip(ByVal sPath As String)
    19.         Dim strZIPHeader As String
    20.  
    21.         strZIPHeader = Chr(80) & Chr(75) & Chr(5) & Chr(6) & String.Format(18, 0)
    22.         CreateObject("Scripting.FileSystemObject").CreateTextFile(sPath).Write(strZIPHeader)
    23.  
    24.     End Sub

  2. #2
    Lively Member
    Join Date
    Jun 2010
    Location
    Spain
    Posts
    92

    Re: Zipping & Unzipping Using Shell32.dll

    Quote Originally Posted by Emcrank View Post
    Ok i didn't like the idea of having to have a 3rd party application stuck in my apps directory so i asked for help on how to do it with the windows built in Shell32.dll. This is what i found out.
    To use this in your own project you need to make a reference to C:\Windows\System32\shell32.dll
    VB.net Code:
    1. 'Remeber to create a reference to C:\Windows\System32\shell32.dll
    2.     Private Sub ExtractZip(ByVal zipFile As String, ByVal destination As String)
    3.         Dim shell As Shell32.Shell = New Shell32.Shell
    4.         shell.NameSpace(destination).CopyHere(shell.NameSpace(zipFile).Items, Nothing)
    5.         shell = Nothing
    6.     End Sub
    7.  
    8.     Public Sub ZipFile(ByVal strFileToZip, ByVal strTargetZip)
    9.         CreateEmptyZip(strTargetZip)
    10.         Try
    11.             CreateObject("Shell.Application").Namespace(strTargetZip).CopyHere(strFileToZip)
    12.         Catch ex As Exception
    13.  
    14.         End Try
    15.     End Sub
    16.  
    17.     Private Sub CreateEmptyZip(ByVal sPath As String)
    18.         Dim strZIPHeader As String
    19.  
    20.         strZIPHeader = Chr(80) & Chr(75) & Chr(5) & Chr(6) & String.Format(18, 0)
    21.         CreateObject("Scripting.FileSystemObject").CreateTextFile(sPath).Write(strZIPHeader)
    22.  
    23.     End Sub
    I wish all the code where as this.
    simple and elegant.
    Thanks!

  3. #3

  4. #4
    Addicted Member
    Join Date
    Aug 2010
    Posts
    137

    Re: Zipping & Unzipping Using Shell32.dll

    please how can i use this to extract archice
    C:/a.zip
    to
    C:/a
    please help
    where can put directories and file in source code

  5. #5
    Member
    Join Date
    Apr 2010
    Posts
    43

    Re: Zipping & Unzipping Using Shell32.dll

    Basic question, I know, but in the first line is the admonition to

    Remeber to create a reference to C:\Windows\System32\shell32.dll
    How exactly does one do that, please?

    Many thanks!

    Edit:

    Ahhh... nevermind! A few minutes of poking around & I found it.

    For anybody who hasn't seen it before (i.e. if you are where I was 10 minutes ago), in VS2010 go to the menu bar & Project > Add Reference > Browse and then navigate to the Windows\System32\shell32.dll.

    And for everyone who already knew that, please disregard all!
    Last edited by HerkyBird; Jan 3rd, 2011 at 10:52 AM.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width