日期:2008-11-28  浏览次数:20544 次

Option Strict Off
Option Explicit On
<System.Runtime.InteropServices.ProgId("Compress_NET.Compress")> Public Class Compress
    
    Public Declare Sub CopyMemory Lib "kernel32" Alias "RtlMoveMemory" (ByRef Destination As Byte, ByRef source As Byte, ByVal Length As Integer)

    Private BitVal() As Integer
    Private CharVal() As Integer
    
    Public Function Compress(ByRef FileArray() As Byte) As Byte
        Dim X As Integer
        Dim Y As Integer
        Dim Z As Integer
        Dim Char_Renamed As Short
        Dim Bitlen As Short
        Dim FileLen_Renamed As Integer
        Dim TelBits As Integer
        Dim TotBits As Integer
        Dim OutStream() As Byte
        Dim TreeNodes(511, 4) As Integer
        Dim BitValue(7) As Byte
        Dim ByteValue As Byte
        Dim ByteBuff As String
        Dim CheckSum As Short
        Dim NumberOfNodes As Short
        Dim OrgNumberOfNodes As Short
        Dim PackedSize As Integer
        Dim DictSize As Integer
        Dim OutPutSize As Integer
        Dim CharCount(255) As Integer
        Dim Bits(255) As String
        Dim Nubits As String
        Dim TempBits As String
        Dim lTemp As Integer
        Dim lWeight As Integer
        Dim rWeight As Integer
        Dim MaxWeight As Integer
        Dim NowWeight As Integer
        Dim lNode As Short
        Dim rNode As Short
        Dim StringBuffer As String
        Dim BitLens(16) As Short
        Dim CharLens(16) As String
        Dim DictString As String
        FileLen_Renamed = UBound(FileArray)
        OutPutSize = -1
        If (FileLen_Renamed = 0) Then
            ReDim Preserve FileArray(2)
            FileArray(0) = 72 'H
            FileArray(1) = 69 'E
            FileArray(2) = 48 '0
            Exit Function
        End If
    &n