Results 1 to 13 of 13

Thread: Decompressing a split ACE archive along with progress bar

  1. #1

    Thread Starter
    New Member
    Join Date
    Feb 2024
    Posts
    6

    Decompressing a split ACE archive along with progress bar

    So I have a split ACE archive and I want to build a very simple VB6 app with a single button and two progress bars.

    On clicking the button, the archive starts getting extracted to some user specified location (but for simplicity assume that it's "D:\dir"). While this extraction is going on, progress bar 1 shows progress for current part of the split archive (e.g. archive.A02), and progress bar 2 shows overall progress (i.e. for the entire extraction process)

    I've googled quite a lot regarding this, but haven't found an answer for my particular use case. I'd be really grateful to get any help on this. thanks!

  2. #2
    Frenzied Member
    Join Date
    Jun 2015
    Posts
    1,069

    Re: Decompressing a split ACE archive along with progress bar

    It might sound simple, but

    I would first start looking for open source implementations of ace archive unpackers. You can probably find some command line ones you could just shell out. They won?t have a feedback mechanism for progress per file though unless you can add that integration in yourself probably in c source code.

    If you find a c source for it you could also make it a dll for better integration. I don?t think there is any windows api or vb implementations of it.

  3. #3
    PowerPoster Arnoutdv's Avatar
    Join Date
    Oct 2013
    Posts
    5,914

    Re: Decompressing a split ACE archive along with progress bar

    Why not use an existing tool?
    Like PeaZip: https://peazip.github.io/ace-files-utility.html

  4. #4

    Thread Starter
    New Member
    Join Date
    Feb 2024
    Posts
    6

    Re: Decompressing a split ACE archive along with progress bar

    Quote Originally Posted by Arnoutdv View Post
    Why not use an existing tool?
    Like PeaZip: https://peazip.github.io/ace-files-utility.html
    I had a look at that one. The thing is, I want to make my own "installer" that mimics those old warez scene installers that were common in the 90s (because of nostalgia reasons). Now those installers had non-typical shapes and all - which I've learned to implement thanks to this forum.

    The thing that's left is decompression with those two tandem progress bars. To be true to those installers I encountered when I was a kid, I'm trying to see if decompressing ace is possible. One option is to just include unace.exe in the same directory and call it from vb, but I don't like that approach. Another is to include some dll (I guess unacev2.dll ? ) and then use some function in VB to invoke for decompression of split archive.

    The second part of the problem is, while that decompression process is going on, the two progress bars should reflect it. IF all this isn't possible with ace format, then I'll move on to rar or zip or whatever. But I'm optimistic, I think the dll approach should work - the only trouble is, I'm completely new to dlls and C programming (if that's involved). Hope that gives the full context

  5. #5
    PowerPoster Arnoutdv's Avatar
    Join Date
    Oct 2013
    Posts
    5,914

    Re: Decompressing a split ACE archive along with progress bar

    There is an unace.dll, the source has never been made available.
    PeaZip free unace utility supports extraction of ACE archives trough Unace.dll, provided by WinAce author as royalty free (but closed source) component - note for Linux users: UNACE is a 32 bit x86 executable, so on Linux 64 bit systems it requires ia32-libs to extract ACE files.

  6. #6

    Thread Starter
    New Member
    Join Date
    Feb 2024
    Posts
    6

    Re: Decompressing a split ACE archive along with progress bar

    Quote Originally Posted by Arnoutdv View Post
    There is an unace.dll, the source has never been made available.
    I understand. In case ace isn't possible, do you know how I can achieve decompression + progress bars using some other format? (e.g. rar)

  7. #7
    Frenzied Member
    Join Date
    Jun 2015
    Posts
    1,069

    Re: Decompressing a split ACE archive along with progress bar

    Zip has an open source dll thats vb usable with lots of code examples in vb
    Im not sure if it supports a progress callback but it would be straightforward to add.
    Search zlib dll vb6

    You could also fake the progress bar and base it on average time and cut it short to keep things simple kinda cheating but..
    Last edited by dz32; Feb 22nd, 2024 at 02:17 PM.

  8. #8
    PowerPoster Zvoni's Avatar
    Join Date
    Sep 2012
    Location
    To the moon and then left
    Posts
    4,446

    Re: Decompressing a split ACE archive along with progress bar

    Quote Originally Posted by sphyrch View Post
    *snip* Another is to include some dll (I guess unacev2.dll ? ) and then use some function in VB to invoke for decompression of split archive.
    *snip*
    Vulnerbility! From 2019. No idea if it's been fixed
    https://borncity.com/win/2019/02/21/...inrar-on-risk/
    Last edited by Zvoni; Tomorrow at 31:69 PM.
    ----------------------------------------------------------------------------------------

    One System to rule them all, One Code to find them,
    One IDE to bring them all, and to the Framework bind them,
    in the Land of Redmond, where the Windows lie
    ---------------------------------------------------------------------------------
    People call me crazy because i'm jumping out of perfectly fine airplanes.
    ---------------------------------------------------------------------------------
    Code is like a joke: If you have to explain it, it's bad

  9. #9

    Thread Starter
    New Member
    Join Date
    Feb 2024
    Posts
    6

    Re: Decompressing a split ACE archive along with progress bar

    Okay so I've googled the crap out of this topic and one thing I found that implements unrar is this: https://vbcoders.com/code/unrar-extr...ord-79419.html

    For your reference, here's the code:

    Module
    Code:
    ' Title: UnRAR VB6 BAS Module
    ' Author: Leigh Bowers (Compulsion Software)
    ' Email: compulsion@esheep.freeserve.co.uk
    ' Version: 1.01
    ' Date: 16th April 1999
    ' Revised: 15th June 1999
    ' Requires: UnRAR.DLL (supplied)
    ' License: Freely Distributable
    
    ' Notes:-
    
    ' Please give me a small mention if you use all or part
    ' of this code in one of your VB programs ;-)
    
    ' Created utilising information contained within the
    ' UnRARDLL.txt & TechNote.txt files (as supplied with
    ' the full WinRAR package).
    
    ' Open Mode Constants
    
    Private Const RAR_OM_LIST As Byte = 0
    Private Const RAR_OM_EXTRACT As Byte = 1
    
    ' Error Constants
    
    Private Const ERAR_NO_MEMORY As Byte = 11
    Private Const ERAR_BAD_DATA As Byte = 12
    Private Const ERAR_BAD_ARCHIVE As Byte = 13
    Private Const ERAR_EOPEN As Byte = 15
    Private Const ERAR_UNKNOWN_FORMAT As Byte = 14
    Private Const ERAR_SMALL_BUF As Byte = 20
    Private Const ERAR_ECLOSE As Byte = 17
    Private Const ERAR_END_ARCHIVE As Byte = 10
    Private Const ERAR_ECREATE As Byte = 16
    Private Const ERAR_EREAD As Byte = 18
    Private Const ERAR_EWRITE As Byte = 19
    
    ' Operation Constants
    
    Private Const RAR_SKIP As Byte = 0
    Private Const RAR_TEST As Byte = 1
    Private Const RAR_EXTRACT As Byte = 2
    
    ' Volume Constants
    
    Private Const RAR_VOL_ASK As Byte = 0
    Private Const RAR_VOL_NOTIFY As Byte = 1
    
    ' User Defined Types
    
    Private Type RARHeaderData
    ArcName As String * 260
    FileName As String * 260
    Flags As Long
    PackSize As Long
    UnpSize As Long
    HostOS As Long
    FileCRC As Long
    FileTime As Long
    UnpVer As Long
    Method As Long
    FileAttr As Long
    CmtBuf As String ' Pointer (char *CmtBuf in C)
    CmtBufSize As Long
    CmtSize As Long
    CmtState As Long
    End Type
    
    Private Type RAROpenArchiveData
    ArcName As String ' Pointer (char *ArcName in C)
    OpenMode As Long
    OpenResult As Long
    CmtBuf As String ' Pointer (char *CmtBuf in C)
    CmtBufSize As Long
    CmtSize As Long
    CmtState As Long
    End Type
    
    ' RAR DLL Declares
    
    Public Declare Function RAROpen Lib "UnRAR.dll" Alias "RAROpenArchive" (ByRef RAROpenData As RAROpenArchiveData) As Long
    Public Declare Function RARClose Lib "UnRAR.dll" Alias "RARCloseArchive" (ByVal HandleToArchive As Long) As Long
    Public Declare Function RARReadHdr Lib "UnRAR.dll" Alias "RARReadHeader" (ByVal HandleToArcRecord As Long, ByRef ArcHeaderRead As RARHeaderData) As Long
    Public Declare Function RARProcFile Lib "UnRAR.dll" Alias "RARProcessFile" (ByVal HandleToArcHeader As Long, ByVal Operation As Long, ByVal DestPath As String, ByVal DestName As String) As Long
    Public Declare Sub RARSetChangeVolProc Lib "UnRAR.dll" (ByVal HandleToArchive As Long, ByVal Mode As Long)
    Public Declare Sub RARSetPassword Lib "UnRAR.dll" (ByVal HandleToArchive As Long, ByVal Password As String)
    and the VB code:
    Code:
    Private Sub Command1_Click()
    ' Description:-
    ' Exrtact file(s) from RAR archive.
    
    ' Parameters:-
    ' sRARArchive   = RAR Archive filename
    ' sDestPath     = Destination path for extracted file(s)
    ' sPassword     = Password [OPTIONAL]
    
    ' Returns:-
    ' Integer       = 0  Failed (no files, incorrect PW etc)
    '                 -1 Failed to open RAR archive
    '                 >0 Number of files extracted
        
    Dim lHandle As Long
    Dim lStatus As Long
    Dim uRAR As RAROpenArchiveData
    Dim uHeader As RARHeaderData
    Dim iFileCount As Integer
        
        RARExtract = -1
        
        ' Open the RAR
    
        uRAR.ArcName = sRARArchive
        uRAR.OpenMode = RAR_OM_EXTRACT
        lHandle = RAROpen(uRAR)
    
        ' Failed to open RAR ?
    
        If uRAR.OpenResult <> 0 Then Exit Function
        
        ' Password ?
        
        If sPassword <> "" Then
            RARSetPassword lHandle, sPassword
        End If
        
        ' Extract file(s)...
        
        iFileCount = 0
    
        ' Is there at lease one archived file to extract ?
        lStatus = RARReadHdr(lHandle, uHeader)
    
        Do Until lStatus <> 0
    
            ' Process (extract) the current file within the archive
            If RARProcFile(lHandle, RAR_EXTRACT, "", sDestPath + uHeader.FileName) = 0 Then
                iFileCount = iFileCount + 1
            End If
            ' Is there another archived file in this RAR ?
            lStatus = RARReadHdr(lHandle, uHeader)
    
        Loop
    
        ' Close the RAR
    
        RARClose lHandle
    
        ' Return
    
        RARExtract = iFileCount
    
    End Function
    End Sub
    The issue is, when I click the Command1 button, it highlights the part "uRAR As RAROpenArchiveData" and throws an error: "user-defined type not defined". Any tweaks to make this work?

  10. #10
    PowerPoster Zvoni's Avatar
    Join Date
    Sep 2012
    Location
    To the moon and then left
    Posts
    4,446

    Re: Decompressing a split ACE archive along with progress bar

    Quote Originally Posted by sphyrch View Post
    Okay so I've googled the crap out of this topic and one thing I found that implements unrar is this: https://vbcoders.com/code/unrar-extr...ord-79419.html

    For your reference, here's the code:

    Module
    Code:
    ' Title: UnRAR VB6 BAS Module
    ' Author: Leigh Bowers (Compulsion Software)
    ' Email: compulsion@esheep.freeserve.co.uk
    ' Version: 1.01
    ' Date: 16th April 1999
    ' Revised: 15th June 1999
    ' Requires: UnRAR.DLL (supplied)
    ' License: Freely Distributable
    
    ' Notes:-
    
    ' Please give me a small mention if you use all or part
    ' of this code in one of your VB programs ;-)
    
    ' Created utilising information contained within the
    ' UnRARDLL.txt & TechNote.txt files (as supplied with
    ' the full WinRAR package).
    
    ' Open Mode Constants
    
    Private Const RAR_OM_LIST As Byte = 0
    Private Const RAR_OM_EXTRACT As Byte = 1
    
    ' Error Constants
    
    Private Const ERAR_NO_MEMORY As Byte = 11
    Private Const ERAR_BAD_DATA As Byte = 12
    Private Const ERAR_BAD_ARCHIVE As Byte = 13
    Private Const ERAR_EOPEN As Byte = 15
    Private Const ERAR_UNKNOWN_FORMAT As Byte = 14
    Private Const ERAR_SMALL_BUF As Byte = 20
    Private Const ERAR_ECLOSE As Byte = 17
    Private Const ERAR_END_ARCHIVE As Byte = 10
    Private Const ERAR_ECREATE As Byte = 16
    Private Const ERAR_EREAD As Byte = 18
    Private Const ERAR_EWRITE As Byte = 19
    
    ' Operation Constants
    
    Private Const RAR_SKIP As Byte = 0
    Private Const RAR_TEST As Byte = 1
    Private Const RAR_EXTRACT As Byte = 2
    
    ' Volume Constants
    
    Private Const RAR_VOL_ASK As Byte = 0
    Private Const RAR_VOL_NOTIFY As Byte = 1
    
    ' User Defined Types
    
    Private Type RARHeaderData
    ArcName As String * 260
    FileName As String * 260
    Flags As Long
    PackSize As Long
    UnpSize As Long
    HostOS As Long
    FileCRC As Long
    FileTime As Long
    UnpVer As Long
    Method As Long
    FileAttr As Long
    CmtBuf As String ' Pointer (char *CmtBuf in C)
    CmtBufSize As Long
    CmtSize As Long
    CmtState As Long
    End Type
    
    Private Type RAROpenArchiveData
    ArcName As String ' Pointer (char *ArcName in C)
    OpenMode As Long
    OpenResult As Long
    CmtBuf As String ' Pointer (char *CmtBuf in C)
    CmtBufSize As Long
    CmtSize As Long
    CmtState As Long
    End Type
    
    ' RAR DLL Declares
    
    Public Declare Function RAROpen Lib "UnRAR.dll" Alias "RAROpenArchive" (ByRef RAROpenData As RAROpenArchiveData) As Long
    Public Declare Function RARClose Lib "UnRAR.dll" Alias "RARCloseArchive" (ByVal HandleToArchive As Long) As Long
    Public Declare Function RARReadHdr Lib "UnRAR.dll" Alias "RARReadHeader" (ByVal HandleToArcRecord As Long, ByRef ArcHeaderRead As RARHeaderData) As Long
    Public Declare Function RARProcFile Lib "UnRAR.dll" Alias "RARProcessFile" (ByVal HandleToArcHeader As Long, ByVal Operation As Long, ByVal DestPath As String, ByVal DestName As String) As Long
    Public Declare Sub RARSetChangeVolProc Lib "UnRAR.dll" (ByVal HandleToArchive As Long, ByVal Mode As Long)
    Public Declare Sub RARSetPassword Lib "UnRAR.dll" (ByVal HandleToArchive As Long, ByVal Password As String)
    and the VB code:
    Code:
    Private Sub Command1_Click()
    ' Description:-
    ' Exrtact file(s) from RAR archive.
    
    ' Parameters:-
    ' sRARArchive   = RAR Archive filename
    ' sDestPath     = Destination path for extracted file(s)
    ' sPassword     = Password [OPTIONAL]
    
    ' Returns:-
    ' Integer       = 0  Failed (no files, incorrect PW etc)
    '                 -1 Failed to open RAR archive
    '                 >0 Number of files extracted
        
    Dim lHandle As Long
    Dim lStatus As Long
    Dim uRAR As RAROpenArchiveData
    Dim uHeader As RARHeaderData
    Dim iFileCount As Integer
        
        RARExtract = -1
        
        ' Open the RAR
    
        uRAR.ArcName = sRARArchive
        uRAR.OpenMode = RAR_OM_EXTRACT
        lHandle = RAROpen(uRAR)
    
        ' Failed to open RAR ?
    
        If uRAR.OpenResult <> 0 Then Exit Function
        
        ' Password ?
        
        If sPassword <> "" Then
            RARSetPassword lHandle, sPassword
        End If
        
        ' Extract file(s)...
        
        iFileCount = 0
    
        ' Is there at lease one archived file to extract ?
        lStatus = RARReadHdr(lHandle, uHeader)
    
        Do Until lStatus <> 0
    
            ' Process (extract) the current file within the archive
            If RARProcFile(lHandle, RAR_EXTRACT, "", sDestPath + uHeader.FileName) = 0 Then
                iFileCount = iFileCount + 1
            End If
            ' Is there another archived file in this RAR ?
            lStatus = RARReadHdr(lHandle, uHeader)
    
        Loop
    
        ' Close the RAR
    
        RARClose lHandle
    
        ' Return
    
        RARExtract = iFileCount
    
    End Function
    End Sub
    The issue is, when I click the Command1 button, it highlights the part "uRAR As RAROpenArchiveData" and throws an error: "user-defined type not defined". Any tweaks to make this work?
    Because "RAROpenArchiveData" is a Private Type in the Bas-Module. Make it Public (and the others, too --> RARHeaderData etc.)
    Last edited by Zvoni; Tomorrow at 31:69 PM.
    ----------------------------------------------------------------------------------------

    One System to rule them all, One Code to find them,
    One IDE to bring them all, and to the Framework bind them,
    in the Land of Redmond, where the Windows lie
    ---------------------------------------------------------------------------------
    People call me crazy because i'm jumping out of perfectly fine airplanes.
    ---------------------------------------------------------------------------------
    Code is like a joke: If you have to explain it, it's bad

  11. #11

    Thread Starter
    New Member
    Join Date
    Feb 2024
    Posts
    6

    Re: Decompressing a split ACE archive along with progress bar

    Quote Originally Posted by Zvoni View Post
    Because "RAROpenArchiveData" is a Private Type in the Bas-Module. Make it Public (and the others, too --> RARHeaderData etc.)
    Thank you! Now the code works - it successfully extracts RAR archives. Just one final thing remaining - the progress bar. Even before the progress bar I'm trying a simpler implementation of listing the files being extracted. So I created listbox called "List1" and modified the VB code as follows (see bold italic):

    Code:
    Private Sub Command1_Click()
    ' Description:-
    ' Exrtact file(s) from RAR archive.
    
    ' Parameters:-
    ' sRARArchive   = RAR Archive filename
    ' sDestPath     = Destination path for extracted file(s)
    ' sPassword     = Password [OPTIONAL]
    
    ' Returns:-
    ' Integer       = 0  Failed (no files, incorrect PW etc)
    '                 -1 Failed to open RAR archive
    '                 >0 Number of files extracted
        
    Dim lHandle As Long
    Dim lStatus As Long
    Dim uRAR As RAROpenArchiveData
    Dim uHeader As RARHeaderData
    Dim iFileCount As Integer
        
        RARExtract = -1
        
        ' Open the RAR
    
        uRAR.ArcName = sRARArchive
        uRAR.OpenMode = RAR_OM_EXTRACT
        lHandle = RAROpen(uRAR)
    
        ' Failed to open RAR ?
    
        If uRAR.OpenResult <> 0 Then Exit Function
        
        ' Password ?
        
        If sPassword <> "" Then
            RARSetPassword lHandle, sPassword
        End If
        
        ' Extract file(s)...
        
        iFileCount = 0
    
        ' Is there at lease one archived file to extract ?
        lStatus = RARReadHdr(lHandle, uHeader)
    
        Do Until lStatus <> 0
    
            ' Process (extract) the current file within the archive
            If RARProcFile(lHandle, RAR_EXTRACT, "", sDestPath + uHeader.FileName) = 0 Then
                iFileCount = iFileCount + 1
                fname = uHeader.FileName
                List1.AddItem fname
            End If
            ' Is there another archived file in this RAR ?
            lStatus = RARReadHdr(lHandle, uHeader)
    
        Loop
    
        ' Close the RAR
    
        RARClose lHandle
    
        ' Return
    
        RARExtract = iFileCount
    
    End Function
    End Sub
    The problem is that while the code is running (i.e. the loop is going through the archive files), none of the filenames appear in the list box. BUT after the whole extraction is over, then all the filenames appear in the list box all at once! I'm not sure why this happens. The loop is going through each file one by one, and before it moves on to the next file, it should finish populating the list box with the filename, no?

    (Another point to note: during the extraction process, while no filenames appear in the list box, a scroll bar does appear in the list box. And the scroll rectangle thingy gets thinner - which indicates several invisible items are getting added to the list box - it's just that they're invisible and only become visible after completion of archive extraction)

    Is there anything I can do so that the list gets updated in real time? If I can do that, then I'm sure even the progress bar can get updated in real time.
    Last edited by sphyrch; Feb 23rd, 2024 at 09:38 AM.

  12. #12
    Smooth Moperator techgnome's Avatar
    Join Date
    May 2002
    Posts
    34,544

    Re: Decompressing a split ACE archive along with progress bar

    This happens because UI updates are given lowest priority in the heierarch because it can be somewhat time consume, so it's sacrificed for performance reasons.
    That said, I think you can use .Refresh on the listbox after adding to it that will force it to update. Just keep in mindm youre addit to the bottom of hte list, so it won't be shown unless the user scrolls to the bottom...

    -tg
    * I don't respond to private (PM) requests for help. It's not conducive to the general learning of others.*
    * I also don't respond to friend requests. Save a few bits and don't bother. I'll just end up rejecting anyways.*
    * How to get EFFECTIVE help: The Hitchhiker's Guide to Getting Help at VBF - Removing eels from your hovercraft *
    * How to Use Parameters * Create Disconnected ADO Recordset Clones * Set your VB6 ActiveX Compatibility * Get rid of those pesky VB Line Numbers * I swear I saved my data, where'd it run off to??? *

  13. #13

    Thread Starter
    New Member
    Join Date
    Feb 2024
    Posts
    6

    Re: Decompressing a split ACE archive along with progress bar

    Quote Originally Posted by techgnome View Post
    This happens because UI updates are given lowest priority in the heierarch because it can be somewhat time consume, so it's sacrificed for performance reasons.
    That said, I think you can use .Refresh on the listbox after adding to it that will force it to update. Just keep in mindm youre addit to the bottom of hte list, so it won't be shown unless the user scrolls to the bottom...

    -tg
    Thanks so much man! That resolved the issue for me.

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