Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. Visual Studio
  4. How to update Progress Bar using "CabLib.dll", on compressing / extracting cab files

How to update Progress Bar using "CabLib.dll", on compressing / extracting cab files

Scheduled Pinned Locked Moved Visual Studio
helpcomtutorialannouncement
6 Posts 2 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • F Offline
    F Offline
    Florin Panescu
    wrote on last edited by
    #1

    I recently found this article Cabinet File (*.CAB) Compression and Extraction[^] is exactly what i want, to make installer with cab files, and is pretty simple to use "Cablib.dll" library, this is my code for compression cab files

    Imports CabLib.Compress

    Public Class Form1

    Public Sub Compress()
        Dim szFiles As ArrayList = New ArrayList
        szFiles.Add(New String() {"C:\\Test\\test.exe", "Destination\\test.exe"})
        Dim szCompress As CabLib.Compress = New CabLib.Compress
        szCompress.CompressFileList(szFiles, "C:\\test\\Cabinet.cab", True, True, 0)
    End Sub
    
    Private Sub BtnCompress\_Click(sender As Object, e As EventArgs) Handles BtnCompress.Click
        BgWorkerCompress.RunWorkerAsync()
    End Sub
    
    Private Sub BgWorkerCompress\_DoWork(sender As Object, e As System.ComponentModel.DoWorkEventArgs) Handles BgWorkerCompress.DoWork
        Compress()
    End Sub
    

    End Class

    i use backgroundworker to avoid non responding form, and now i want to add progressbar to see the progress when i make cab files, so here im stuck and i don't know how to do that, i have tried using

    CabLib.Compress.delUpdateStatus()

    and it say

    Quote:

    Error 2 'delUpdateStatus' is a type in 'CabLib.Compress' and cannot be used as an expression.

    I hope someone help me with this. Sorry my bad english.

    L F 2 Replies Last reply
    0
    • F Florin Panescu

      I recently found this article Cabinet File (*.CAB) Compression and Extraction[^] is exactly what i want, to make installer with cab files, and is pretty simple to use "Cablib.dll" library, this is my code for compression cab files

      Imports CabLib.Compress

      Public Class Form1

      Public Sub Compress()
          Dim szFiles As ArrayList = New ArrayList
          szFiles.Add(New String() {"C:\\Test\\test.exe", "Destination\\test.exe"})
          Dim szCompress As CabLib.Compress = New CabLib.Compress
          szCompress.CompressFileList(szFiles, "C:\\test\\Cabinet.cab", True, True, 0)
      End Sub
      
      Private Sub BtnCompress\_Click(sender As Object, e As EventArgs) Handles BtnCompress.Click
          BgWorkerCompress.RunWorkerAsync()
      End Sub
      
      Private Sub BgWorkerCompress\_DoWork(sender As Object, e As System.ComponentModel.DoWorkEventArgs) Handles BgWorkerCompress.DoWork
          Compress()
      End Sub
      

      End Class

      i use backgroundworker to avoid non responding form, and now i want to add progressbar to see the progress when i make cab files, so here im stuck and i don't know how to do that, i have tried using

      CabLib.Compress.delUpdateStatus()

      and it say

      Quote:

      Error 2 'delUpdateStatus' is a type in 'CabLib.Compress' and cannot be used as an expression.

      I hope someone help me with this. Sorry my bad english.

      L Offline
      L Offline
      Lost User
      wrote on last edited by
      #2

      As far as I can discover delUpdateStatus is a delegate type and needs to be set to point to a delegate method. It is not a method that you can call directly. Google will find you samples of use.

      F 1 Reply Last reply
      0
      • L Lost User

        As far as I can discover delUpdateStatus is a delegate type and needs to be set to point to a delegate method. It is not a method that you can call directly. Google will find you samples of use.

        F Offline
        F Offline
        Florin Panescu
        wrote on last edited by
        #3

        I have searching how to delegate but i don't know how to use one delegate on this "Cablib.dll". My skils is beginner, i forgot to say that.

        L 1 Reply Last reply
        0
        • F Florin Panescu

          I have searching how to delegate but i don't know how to use one delegate on this "Cablib.dll". My skils is beginner, i forgot to say that.

          L Offline
          L Offline
          Lost User
          wrote on last edited by
          #4

          See http://msdn.microsoft.com/en-us/library/aa288459(v=vs.71).aspx[^]. Any other questions on this library should be posted to the forum at the end of the article.

          1 Reply Last reply
          0
          • F Florin Panescu

            I recently found this article Cabinet File (*.CAB) Compression and Extraction[^] is exactly what i want, to make installer with cab files, and is pretty simple to use "Cablib.dll" library, this is my code for compression cab files

            Imports CabLib.Compress

            Public Class Form1

            Public Sub Compress()
                Dim szFiles As ArrayList = New ArrayList
                szFiles.Add(New String() {"C:\\Test\\test.exe", "Destination\\test.exe"})
                Dim szCompress As CabLib.Compress = New CabLib.Compress
                szCompress.CompressFileList(szFiles, "C:\\test\\Cabinet.cab", True, True, 0)
            End Sub
            
            Private Sub BtnCompress\_Click(sender As Object, e As EventArgs) Handles BtnCompress.Click
                BgWorkerCompress.RunWorkerAsync()
            End Sub
            
            Private Sub BgWorkerCompress\_DoWork(sender As Object, e As System.ComponentModel.DoWorkEventArgs) Handles BgWorkerCompress.DoWork
                Compress()
            End Sub
            

            End Class

            i use backgroundworker to avoid non responding form, and now i want to add progressbar to see the progress when i make cab files, so here im stuck and i don't know how to do that, i have tried using

            CabLib.Compress.delUpdateStatus()

            and it say

            Quote:

            Error 2 'delUpdateStatus' is a type in 'CabLib.Compress' and cannot be used as an expression.

            I hope someone help me with this. Sorry my bad english.

            F Offline
            F Offline
            Florin Panescu
            wrote on last edited by
            #5

            Yeeeee i done to extract with progress bar, but i have one problem, the progress bar is updating like steps progress, not smoothing, and if i not put the code

            System.Threading.Thread.Sleep(100)

            the extraction will be extremely fast, how to make progress bar to update like +1 value not steps?... This is my code for extraction cab:

            Imports CabLib.Extract
            Imports System
            Imports System.IO
            Imports System.Threading

            Public Class Form1

            Private szFiles As ArrayList = New ArrayList
            Private FileCount As Integer = 0
            Private TotalSize As Long = 0, Total As Long = 0, LastVal As Long = 0, Sum As Long = 0
            
            Public Function OnBeforeCopyFile(ByVal k\_Info As CabLib.Extract.kProgressInfo)
                System.Threading.Thread.Sleep(100)
                TotalSize = k\_Info.u32\_TotSize
                BgWorkerExtract.ReportProgress(CInt(k\_Info.u32\_Written))
                Return k\_Info
            End Function
            
            Public Sub ExtractCab(ByVal CabFile As String, ByVal szPath As String)
                Dim szExtract As CabLib.Extract = New CabLib.Extract()
                AddHandler szExtract.evProgressInfo, AddressOf OnBeforeCopyFile
                szExtract.ExtractFile(CabFile, szPath)
            End Sub
            
            Private Sub BgWorkerExtract\_ProgressChanged(sender As Object, e As ComponentModel.ProgressChangedEventArgs) Handles BgWorkerExtract.ProgressChanged
                StatusBar.Maximum = CInt(TotalSize)
                StatusBar.Value = e.ProgressPercentage
            End Sub
            
            Private Sub BtnExtract\_Click(sender As Object, e As EventArgs) Handles BtnExtract.Click
                BgWorkerExtract.RunWorkerAsync()
            End Sub
            
            Private Sub BgWorkerExtract\_DoWork(sender As Object, e As System.ComponentModel.DoWorkEventArgs) Handles BgWorkerExtract.DoWork
                ExtractCab("C:\\test\\Cabinet.cab", "C:\\Test\\Parts")
            End Sub
            

            End Class

            F 1 Reply Last reply
            0
            • F Florin Panescu

              Yeeeee i done to extract with progress bar, but i have one problem, the progress bar is updating like steps progress, not smoothing, and if i not put the code

              System.Threading.Thread.Sleep(100)

              the extraction will be extremely fast, how to make progress bar to update like +1 value not steps?... This is my code for extraction cab:

              Imports CabLib.Extract
              Imports System
              Imports System.IO
              Imports System.Threading

              Public Class Form1

              Private szFiles As ArrayList = New ArrayList
              Private FileCount As Integer = 0
              Private TotalSize As Long = 0, Total As Long = 0, LastVal As Long = 0, Sum As Long = 0
              
              Public Function OnBeforeCopyFile(ByVal k\_Info As CabLib.Extract.kProgressInfo)
                  System.Threading.Thread.Sleep(100)
                  TotalSize = k\_Info.u32\_TotSize
                  BgWorkerExtract.ReportProgress(CInt(k\_Info.u32\_Written))
                  Return k\_Info
              End Function
              
              Public Sub ExtractCab(ByVal CabFile As String, ByVal szPath As String)
                  Dim szExtract As CabLib.Extract = New CabLib.Extract()
                  AddHandler szExtract.evProgressInfo, AddressOf OnBeforeCopyFile
                  szExtract.ExtractFile(CabFile, szPath)
              End Sub
              
              Private Sub BgWorkerExtract\_ProgressChanged(sender As Object, e As ComponentModel.ProgressChangedEventArgs) Handles BgWorkerExtract.ProgressChanged
                  StatusBar.Maximum = CInt(TotalSize)
                  StatusBar.Value = e.ProgressPercentage
              End Sub
              
              Private Sub BtnExtract\_Click(sender As Object, e As EventArgs) Handles BtnExtract.Click
                  BgWorkerExtract.RunWorkerAsync()
              End Sub
              
              Private Sub BgWorkerExtract\_DoWork(sender As Object, e As System.ComponentModel.DoWorkEventArgs) Handles BgWorkerExtract.DoWork
                  ExtractCab("C:\\test\\Cabinet.cab", "C:\\Test\\Parts")
              End Sub
              

              End Class

              F Offline
              F Offline
              Florin Panescu
              wrote on last edited by
              #6

              I have another problem with extraction cab progress, is extracting but for every file my progress bar will update to 100%, i want my progress bar to update until all files is extracted, how to do that? :( i was playing with the codes but no luck, this is my code for now:

              Imports CabLib.Compress
              Imports CabLib.Compress.kCurStatus
              Imports CabLib.Extract
              Imports System
              Imports System.IO
              Imports System.Runtime.InteropServices
              Imports Microsoft.VisualBasic

              Public Class Form1

              Private szFiles As ArrayList = New ArrayList
              Private FileCount As Integer = 0
              Private TotalSize As Long = 0, Total As Long = 0, LastVal As Long = 0, Sum As Long = 0
              
                 Private Delegate Sub StatusText(ByVal Status As String)
              

              #Region " Status text "
              Public Function CabinetInfo(ByVal InfoCab As String)
              If Me.InvokeRequired Then
              Me.Invoke(New StatusText(AddressOf CabinetInfo), InfoCab)
              Else
              Label1.Text = InfoCab
              End If
              Return True
              End Function
              #End Region

              #Region " Progress Extract Function "
              Public Function ProgressExtract(ByVal k_Info As CabLib.Extract.kProgressInfo) As Integer

                  If Total <> k\_Info.u32\_TotSize Then
                     CabinetInfo(k\_Info.s\_FullPath)
                      Sum = k\_Info.u32\_Written
                      TotalSize = k\_Info.u32\_TotSize
                   Else
                      Total += k\_Info.u32\_Written - LastVal
                  End If
                  LastVal = k\_Info.u32\_Written
                  BgWorkerExtract.ReportProgress(CInt(Sum))
              
                  Return True
              
              End Function
              

              #End Region

              Public Sub ExtractCab(ByVal CabFile As String, ByVal szPath As String)
              
                  Try               
                    Dim szExtract As CabLib.Extract = New CabLib.Extract
                    
                    AddHandler szExtract.evProgressInfo, AddressOf ProgressExtract
                    szExtract.ExtractFile(CabFile, szPath)
                  Catch ex As Exception
                      System.Windows.Forms.MessageBox.Show(ex.Message)
                  End Try
              End Sub
              
              Private Sub BgWorkerExtract\_ProgressChanged(sender As Object, e As ComponentModel.ProgressChangedEventArgs) Handles BgWorkerExtract.ProgressChanged
                  StatusBar.Maximum = CInt(TotalSize)
                  StatusBar.Value = e.ProgressPercentage
              End Sub
              
              Private Sub BtnExtract\_Click(sender As Object, e As EventArgs) Handles BtnExtract.Click
                  BgWorkerExtract.RunWorkerAsync()
              End Sub
              
              Private Sub BgWorkerExtract\_DoWork(sender As Object, e As System.ComponentModel.DoWorkEventArgs) Handles BgW
              
              1 Reply Last reply
              0
              Reply
              • Reply as topic
              Log in to reply
              • Oldest to Newest
              • Newest to Oldest
              • Most Votes


              • Login

              • Don't have an account? Register

              • Login or register to search.
              • First post
                Last post
              0
              • Categories
              • Recent
              • Tags
              • Popular
              • World
              • Users
              • Groups