So nachdem ich den Tipp bekommen habe, dass die zlib.dll keine Funktionen zum registrieren am System hat, wird sie jetzt einfach von mir nicht mehr beim installieren registriert und siehe da es funktioniert.
Jetzt habe ich gemerkt, dass die Routine zum entpacken zwar funktioniert, allerdings hin und wieder einen Fehler produziert bei groesseren Dateien und zwar beim entpacken.
Getestet habe ich damit eine 77MB Datei die auf 2,3MB damit gepackt wurde und beim entpacken sagen wir mal bei allen 5 Versuchen im Durchschnitt einen Fehler erzeugt.
Allderdings habe ich kein Tutorial oder der gleichen im Netz finden koennen zu der zlib.dll in der RFC1950 dazu steht auch nicht wirklich hilfreiches zu dem Problem drin.
Mein Problem ist folgendes dass ich irgendwann nen Buffer Overflow bekomme. Und dann in der Select Case - Abfrage gibt er mir natürlich folgende Meldung aus. Wäre aber fein wenn ich den Overflow irgendwie vermeiden könnte.
Case Z_BUF_ERROR
MsgBox "Buffer too small", vbExclamation, _
"Compression Error" Kennt sich jemand näher mit dieser zlib.dll aus und weiss woran das liegen koennte bzw. wie man das ganze umgehen oder abfangen kann?
Schon mal grosses Danke an alle die mir bisher hier geholfen haben, auch wenn man fuer das Problem hier keine Loesung finden sollte.
So sieht der gesammte Code dazu aus, falls sich jemand dafür interessieren sollte:
Option Explicit
' Either place the library in the System directory
' or specify the full path to zlib.dll here.
Private Declare Function uncompress Lib "zlib.dll" (dest As Any, destLen As _
Any, src As Any, ByVal srcLen As Long) As Long
Private Const Z_OK = 0
Private Const Z_DATA_ERROR = -3
Private Const Z_MEM_ERROR = -4
Private Const Z_BUF_ERROR = -5
Public Function decompress()
Dim file_name As String
Dim fnum As Integer
Dim compressed_size As Long
Dim compressed_bytes() As Byte
Dim uncompressed_size As Long
Dim uncompressed_bytes() As Byte
' **************************************
' Load the file into a byte array.
file_name = App.Path & "\Updates\" & FileName
compressed_size = FileLen(file_name)
ReDim compressed_bytes(1 To compressed_size)
fnum = FreeFile
Open file_name For Binary Access Read As #fnum
Get #fnum, , compressed_bytes()
Close #fnum
' **************************************
' Uncompress.
' Allocate room for the uncompressed file.
' Note that this routine needs to know
' the original file's uncompressed size.
uncompressed_size = Val(INIGetValue(INIFile2, "Update", "File" & i & _
"_decompressedSize"))
ReDim uncompressed_bytes(1 To uncompressed_size)
' Decompress the bytes.
Select Case uncompress( _
uncompressed_bytes(1), uncompressed_size, _
compressed_bytes(1), compressed_size)
Case Z_MEM_ERROR
MsgBox "Insufficient memory", vbExclamation, _
"Compression Error"
Exit Function
Case Z_BUF_ERROR
MsgBox "Buffer too small", vbExclamation, _
"Compression Error"
Exit Function
Case Z_DATA_ERROR
MsgBox "Input file corrupted", vbExclamation, _
"Compression Error"
Exit Function
' Else Z_OK.
End Select
' Copy the existing file to the Folder Old
On Error Resume Next
FileCopy App.Path & "\" & INIGetValue(INIFile2, "Update", "File" & i & _
"_decompressed"), App.Path & "\Old\" & INIGetValue(INIFile2, "Update", _
"File" & i & "_decompressed") & "_" & Left(Date, 2) & Mid(Date, 4, 2) & _
Right(Date, 4)
' **************************************
' Save the results into the output file.
On Error Resume Next
Kill file_name
' Write the file.
file_name = App.Path & "\" & INIGetValue(INIFile2, "Update", "File" & i & _
"_decompressed")
Open file_name For Binary Access Write As #fnum
Put #fnum, , uncompressed_bytes()
Close #fnum
End Function |