|
1 members (Russ),
11,481
guests, and
1,562
robots. |
|
Key:
Admin,
Global Mod,
Mod
|
|
|
S |
M |
T |
W |
T |
F |
S |
|
|
|
1
|
2
|
3
|
4
|
5
|
|
6
|
7
|
8
|
9
|
10
|
11
|
12
|
|
13
|
14
|
15
|
16
|
17
|
18
|
19
|
|
20
|
21
|
22
|
23
|
24
|
25
|
26
|
|
27
|
28
|
29
|
30
|
31
|
|
|
|
|
This is another custom island. This one could be used for ads. This spot is one of the best places for ads on your site to be placed. This can be enabled/disabled on a per forum basis.
|
|
|
|
Joined: Dec 1999
Posts: 30,868
Master Elite Member
|
Private Function ZipPK_MM(Val() As Byte, Password As String, ZipControl As Zip, ByRef Status() As Variant) As Byte()
'Purpose
' Used to compress a value and return the result as a byte array.
'Parameters
' Val (Byte()) = The value we want to compress.
' Password (String) = A password used to decrypt the value.
' A password is not used to decode the value if it is zero-length.
' ZipControl (Zip) = A reference to the Dart Zip control we're going to use for compression.
' Status (Variant()) = A standard rtStatus array. This is used to return status information.
' Returned status values are taken directly from the Dart Zip control and DartStream objects.
' Status conditions are reported in the first two elements only. Any additional elements are unchanged.
' This must enter with two or more elements (zero-based) or function may crash.
'Return (Byte())
' Returns the specified value compressed.
' If an error occurs, returns an empty Byte array.
'Exit Conditions
' The FileStore object of the Zip control has been altered.
'Dependencies
' The Dart "Zip" control must be referenced in the hosting application.
' The following functions must be directly callable:
' IsEmptyArray
'Version History
' 1.0 7/4/2004 Tested by Russ Tanner
'---
'Set status trap
On Error GoTo ZipPK_MM_Error:
'Initiate variables
Dim StreamIn As New DartStream
Dim StreamOut As New DartStream
Dim EmptyByteArray() As Byte
'Clear the status condition
Status(0) = CLng(0)
Status(1) = ""
'Remove all previous files from the FileStore
ZipControl.FileStore.Clear
'Add the specified value (Val) to a DartStream
'WORKAROUND: DARTSOCK.DLL generates a critical "Access Violation" when
'an empty byte array is passed to the Dart Zip control.
'If Val enters with zero elements, pass a zero-length string to the input stream
If isEmptyArray(Val) Then
StreamIn.Write ""
Else
StreamIn.Write Val
End If
'Zip the value. Use a password only if it is specified.
If Password = "" Then
ZipControl.FileStore.Add StreamIn, False, False, "", zipNoEncryption
Else
ZipControl.FileStore.Add StreamIn, False, False, Password, zipStandard
End If
'Zip the value to a compressed DartStream
ZipControl.FileStore.Zip StreamOut
'Remove all previous files from the FileStore
ZipControl.FileStore.Clear
'Return the result
StreamOut.Position = 0 'Must rewind the stream to read from it
ZipPK_MM = StreamOut.ReadBytes 'Return the compressed value
Exit Function
'Error Trap
ZipPK_MM_Error:
'An error occured, return an empty byte array
ZipPK_MM = EmptyByteArray
'Remove all previous files from the FileStore
ZipControl.FileStore.Clear
'Return the error information
Status(0) = Err.Number
Status(1) = Err.Description
End Function
|
|
|
|
|