D
Dennis Powell
Does anyone have a successful implementaion of the zlib.dll in VB. Net they
can show me. I'm writting a class encaplsulating zlib functionality and I
keep getting a System.NullReferenceException (Object reference not set to an
instance of an object) when I try to call the dll's compress function.
The function in the dll is declared as such:
int compress (Bytef *dest, uLongf *destLen, const Bytef *source, uLong
sourceLen)
I've declared it as such in my class:
Private Declare Function Shrink Lib "zlib.dll" Alias "compress" _
(ByRef strCompressed As String, ByRef lngCompressedLen As
Long, _
ByVal strToCompress As String, ByVal strToCompressLen As
Long) As Long
Implemented in the class:
Public Sub Compress()
Dim rVal as Long 'return value from the function
' all values passed to zlib.dll are class private member variables
' m_strCompressed - a buffer(string) at least 1% + 12 characters larger than
the string to compress (required by the compress function) that the
compressed string ' is returned in. Initialized in the StrToCompress
Property Set this way: m_strCompressed = New String(" ",
(Len(m_strToCompress) * 1.01) + 13)
' m_lngCompressedLen - the length of the return buffer when called and holds
the actual length when it returns.
' m_strToCompress - the string that will be compressed
' m_lngStringLen - the length of the string that will be compressed
rVal = Shrink(m_strCompressed, m_lngCompressedLen, m_strToCompress,
m_lngStringLen)
I get the exception on the above line:
I used the zlib.dll in the VB6 version of my program without any problems.
The only difference is the lngCompressedLen was declared as 'As Any' which
is not possible in .Net. I'm re-writing the program in VB .Net and need to
maintain compatibility with the VB6 Version as far as compressing and
decompressing files is concerned.
Any help would be greatly appreciated.
Thanks,
Dennis
can show me. I'm writting a class encaplsulating zlib functionality and I
keep getting a System.NullReferenceException (Object reference not set to an
instance of an object) when I try to call the dll's compress function.
The function in the dll is declared as such:
int compress (Bytef *dest, uLongf *destLen, const Bytef *source, uLong
sourceLen)
I've declared it as such in my class:
Private Declare Function Shrink Lib "zlib.dll" Alias "compress" _
(ByRef strCompressed As String, ByRef lngCompressedLen As
Long, _
ByVal strToCompress As String, ByVal strToCompressLen As
Long) As Long
Implemented in the class:
Public Sub Compress()
Dim rVal as Long 'return value from the function
' all values passed to zlib.dll are class private member variables
' m_strCompressed - a buffer(string) at least 1% + 12 characters larger than
the string to compress (required by the compress function) that the
compressed string ' is returned in. Initialized in the StrToCompress
Property Set this way: m_strCompressed = New String(" ",
(Len(m_strToCompress) * 1.01) + 13)
' m_lngCompressedLen - the length of the return buffer when called and holds
the actual length when it returns.
' m_strToCompress - the string that will be compressed
' m_lngStringLen - the length of the string that will be compressed
rVal = Shrink(m_strCompressed, m_lngCompressedLen, m_strToCompress,
m_lngStringLen)
I get the exception on the above line:
I used the zlib.dll in the VB6 version of my program without any problems.
The only difference is the lngCompressedLen was declared as 'As Any' which
is not possible in .Net. I'm re-writing the program in VB .Net and need to
maintain compatibility with the VB6 Version as far as compressing and
decompressing files is concerned.
Any help would be greatly appreciated.
Thanks,
Dennis