How to update Progress Bar using "CabLib.dll", on compressing / extracting cab files
-
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.
-
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.
-
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.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.
-
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.
-
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.
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.ThreadingPublic 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
-
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.ThreadingPublic 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
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.VisualBasicPublic 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 IntegerIf 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