• To get Zip/Unzip API to work (VB .Net 2005 Express Edition)

    Home » Forums » Developers, developers, developers » DevOps Lounge » To get Zip/Unzip API to work (VB .Net 2005 Express Edition)

    Author
    Topic
    #427525

    I am trying to learn VB .Net 2005 Express Edition from a VB 1 (It has been a few years) background. I have the need to invoke Zip functionality from within VB code. Looking around the net, I find that the InfoZip organization seems to be the most prominent (and free). so I downloaded a page of instructions and a directory of support files. (The attached Zip file contains those support files: the first file, AnArticle.txt, is the instruction page mentioned above; the two DLL’s have been left out to keep the attachment size down.) And while the sample code in those instructions is straight forward, I cannot figure out how to use the support files.

    Here’s what I did: 1) I copied the two DLL’s (Zip32.dll – 130KB and Unzip32.dll – 140KB) to C:WindowsSystem32, but that did not seem to do anything. 2) I defined a CGZipFiles Class into which I copied the contents of the CGZipFiles.cls file, but all that did was generate masses of compiler error messages. So where I now stand is that I’ve entered the following code into VB’s IDE and have not the faintest idea where to go from from here.

    Module Module1
    Sub Main()
    Dim oZip As CGZipFiles
    oZip = New CGZipFiles
    ‘ The rest of the code copied from the instructions.

    End Sub
    Class CGZipFiles
    ‘ I have no idea what to put in here.
    End Class
    End Module

    Will someone please explain in detail how I can get this to work? Thank you for your time and patience.

    John Littell

    Viewing 1 reply thread
    Author
    Replies
    • #990808

      To help read it, attached is a Zip of the instructions file AnArticle.zip in its original .rtf format.

    • #990845

      Visual Studio doesn’t care where the DLL is located and will usually create a local copy of any referenced DLL that is not registered in the Global Assembly Cache (GAC – located at C:WindowsAssembly).

      It appears that the DLL you’ve referenced is a COM DLL (i.e. NOT created with .NET). The process for referencing an external DLL is similar with COM and .NET dlls. Look for the “Add Reference” menu option (I don’t use the Express Edition so I’m not sure where to tell you to look). Add a reference to the DLL – be sure to specify that it’s a COM DLL and not .NET.

      After the reference is added, the code examples for VB6 should work.

      Hope this helps.

      • #990914

        Mark,
        Thank you for jumping in. I found Project, Add Reference… and received the Add Reference dialog. It contains five tabs: .NET, COM, Projects, Browse, and Recent. The COM tab produced a list of hundreds of DLLs but did not list either my Zip32.DLL or Unzip32.DLL. Neither did the .NET tab and the Projects and Recent tabs are empty. The browse tab did list them but when I selected Zip32.DLL I received an error saying “A reference to ‘C:WINDOWSSYSTEM32zip32.dll’ coult not be added. Please make sure that the file is accessible, and that it is a valid assembly or COM component.”

        Please send instructions. (Separate question: If I do get the two DLLs added as required, does this mean that all the source files are there only for information and that they will not be needed to create separate Classes?)

        John Littell

        • #990916

          Mark,
          I should have included this in my last reply, but, in case it helps, attached is a ziped copy of ZIP32.DLL.

          John

        • #990985

          The only DLLs that will belisted are those that have been registered on the system.

          Most good VB 6 books will explain how to register a DLL.

          Also, a book such as the VB .NET Step by Step from mSFT Press descibes adding a reference.

        • #990986

          You’ll want to research using unmanaged, COM, or VB6 DLLs (basically the same thing) with .NET.

          A good place to start is the help that comes with Visual Basic. You can also check out this article on MSDN.

          • #991056

            Thanks Howard, thanks Mark,
            Can someone please be a little bit more specific about registering my two dlls? I’ve searched through my two learning VB books “Sam’s Teach Yourself Visual Basic .NET 2003” and “Visual Basic 2005 Express Edition Build a Program Now” from Microsoft and found no such subject. And I’ve looked in the help systems of my three compilers “MS VB 2005 Express Edition”, “MS VB 2003 .Net” and “MS VBA for Access” (listed as VB 6.3). and again found no such subject. I can only assume that I’m using the wrong terms.

            Meanwhile I’m exploring unmanaged code with .Net. Is this the alternative to registration??

            John Littell

            • #991073

              Registering DLLs would be covered in VB 6, not VB .NET, books.
              For example, Gary Cornell’s Visual Bsaic 6 FRom the Ground Up.

            • #991160

              There is a link in post 436,244 that explains using RegSvr32 to register a dll. You can also search the VB/VBA forum for more references to regsvr32 for more information.

            • #991219

              Charlotte, thank you for joining in.

              Now that I know about RegSvr32, I found lots of information in past conversations. Not, however, anything regarding the error I got when I ran it. The error message is “Zip32.dll was loaded, but the DllRegisterServer entry point was not found. This file can not be registered.” Any ideas?

              (Remember, the point of this questioning is not necessarily how to register these two dlls, but how to access them from VB code in the VB .Net 2005 environment. If the way is to register, then I’ll do it… somehow. If not, is there another way?)

              John

            • #991252

              If I remember correctly, that means it isn’t a dll you can use that way, it’s part of an application library. Since the library is built for VB5/VB6, you may not be able to use it at all in VB.Net and you certainly can’t just paste the code in those VB classes into .Net and expect it to work. You would at the very least need to rewrite the code in the bas file into VB.Net.

    Viewing 1 reply thread
    Reply To: To get Zip/Unzip API to work (VB .Net 2005 Express Edition)

    You can use BBCodes to format your content.
    Your account can't use all available BBCodes, they will be stripped before saving.

    Your information: