Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/.net/25.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
我需要将zLib1.dll与Visual Basic.NET一起使用_.net_Zlib - Fatal编程技术网

我需要将zLib1.dll与Visual Basic.NET一起使用

我需要将zLib1.dll与Visual Basic.NET一起使用,.net,zlib,.net,Zlib,我正在研究一些古老的C代码,它使用zLib1.dll来解压缩一个缓和文件。我需要一个例子,说明如何使用Visual Basic.NET访问DLL中的“解压缩”函数 我知道可能会出现这种情况,所以以下是我研究过的一些事情: 我知道zLib1.dll有一个.NET包装器。事实上,如果您下载源代码,它甚至会出现在zip文件中。问题是帮助文件(chm)无法为我打开,因此我无法阅读文档 这可能是一个解决方案。。。我见过有人提到使用内置压缩。。。但这和zLib完全一样吗?如果一个文件没有使用与zLib相同的

我正在研究一些古老的C代码,它使用zLib1.dll来解压缩一个缓和文件。我需要一个例子,说明如何使用Visual Basic.NET访问DLL中的“解压缩”函数

我知道可能会出现这种情况,所以以下是我研究过的一些事情:

  • 我知道zLib1.dll有一个.NET包装器。事实上,如果您下载源代码,它甚至会出现在zip文件中。问题是帮助文件(chm)无法为我打开,因此我无法阅读文档

  • 这可能是一个解决方案。。。我见过有人提到使用内置压缩。。。但这和zLib完全一样吗?如果一个文件没有使用与zLib相同的算法,那么我尝试解压它是没有好处的

  • 请不要只是建议我使用winzip或其他类似的东西,因为它不起作用。这些安抚文件有一些特殊的头,罐装软件包无法理解。我必须能够解压缩文件中的特定字节

  • 回答我自己的问题(某种程度上)它看起来确实像内置的压缩工作得很好。这是我的最终解决方案:(AltDecompress是完成解压缩的地方,它调用GetDataBlock,为了清楚起见,我已经包括了GetDataBlock

    Public Function AltDecompress(data As Byte()) As Byte()
        Dim output = New MemoryStream()
    
        Dim tmp As Byte() = GetDataBlock(data, 2)  ' using .NET we have to strip the zLib header
        Using compressedStream = New MemoryStream(tmp)
            Using zlibStream = New DeflateStream(compressedStream, CompressionMode.Decompress)
                zlibStream.CopyTo(output)
                zlibStream.Close()
                output.Position = 0
                Return output.ToArray
            End Using
        End Using
    End Function
    
    
    Public Function GetDataBlock(ByRef Data As Byte(), ByVal start As Integer, Optional ByVal len As Integer = 0) As Byte()
        ' Extract a datablock from another datablock
        ' if len is not specified it will copy the entire block from the starting point to the end
        Dim BlockLen As Integer = Data.Length - start           ' Calculate the length of the data block
    
        ' Check if len was specified
        If len = 0 Then
            ' if not grab everything from start to end
            BlockLen = Data.Length - start
        Else
            ' Grab just the data asked for
            BlockLen = len
        End If
    
        Dim tmpBlock(BlockLen) As Byte   ' Create the target array
        Array.ConstrainedCopy(Data, start, tmpBlock, 0, BlockLen)   ' Copy the data
        Return tmpBlock  ' return the block
    
    End Function
    

    我有两个建议给你:试着用内置功能解压文件,看看它是否有效。如果失败,谷歌如何在你使用的系统上打开chm文件。-第三,如果我的第一个建议无效:在
    古C
    中编写一个可以解压专有文件的应用程序,然后(re)使用.NET内置支持的算法对其进行压缩。如果有人遇到此问题,我会找到我自己问题的答案(某种程度上)。
    \upublic Shared Function解压缩(ByRef dest As Byte()、ByVal destlen As ULong、ByRef src As Byte()、ByVal srclen As ULong)作为Integer End函数
    唯一的问题是,当它访问函数并执行我告诉它的操作时…它不起作用。抛出访问冲突,因此返回到绘图板。。。。