以下的代码是已经调试正常了的,用以读取一个二进制文件每64kb生成一个crc32的索引,但效率不太高.
求高人帮忙提供一下调用readfile等api该如何写啊?
Private Sub Command1_Click()Label2.Caption = Time
Dim x() As Byte
Dim CRC32 As CRC32, lResult As Long
Set CRC32 = New CRC32Open Text1.Text For Binary Access Read As #1
'Open "d:\2.rar" For Binary Access Write As #2
Open "d:\1.txt" For Append As #3
buff = LOF(1)ReDim x(65535 - 1)
For ii = 1 To Int(LOF(1) / 65535)
DoEventsLabel1.Caption = Int(ii / Int(LOF(1) / 65535) * 100) & "%"
buff = buff - 65535
Get #1, , x
lResult = CRC32.CRC(x)
Print #3, Hex(lResult)
'Put #2, , x
Next ii
ReDim x(buff - 1)
Get #1, , x
lResult = CRC32.CRC(x)
Print #3, Hex(lResult)
'Put #2, , x
Close #1
'Close #2
Close #3
Label3.Caption = Time
End Sub
求高人帮忙提供一下调用readfile等api该如何写啊?
Private Sub Command1_Click()Label2.Caption = Time
Dim x() As Byte
Dim CRC32 As CRC32, lResult As Long
Set CRC32 = New CRC32Open Text1.Text For Binary Access Read As #1
'Open "d:\2.rar" For Binary Access Write As #2
Open "d:\1.txt" For Append As #3
buff = LOF(1)ReDim x(65535 - 1)
For ii = 1 To Int(LOF(1) / 65535)
DoEventsLabel1.Caption = Int(ii / Int(LOF(1) / 65535) * 100) & "%"
buff = buff - 65535
Get #1, , x
lResult = CRC32.CRC(x)
Print #3, Hex(lResult)
'Put #2, , x
Next ii
ReDim x(buff - 1)
Get #1, , x
lResult = CRC32.CRC(x)
Print #3, Hex(lResult)
'Put #2, , x
Close #1
'Close #2
Close #3
Label3.Caption = Time
End Sub
如果硬盘不支持这个速度的话,到时候你的内存消耗量可以说的天文数字.
所以并不是说数组越大速度越快的(除非你的配置是超人配置,问题是你要考虑一下你的客户)你应该在复制文件的时候,从小数组开始(我一般是从8KB开始),然后逐渐递增(每4KB递增一次)
然后判断它的处理速度,如果速度比之前的还要慢的话,就维持之前的速度,过一段时间再进行递增反正我的最佳速度一般维持在32KB左右,就是大概每秒10~16MB左右的速度,可能是我的硬盘问题吧!
Function T1()
Dim V, B() As Byte
V = 12345678
ReDim B(V)
MsgBox UBound(B)
End Function