代码1
Public Function GetImageFile(ByVal sFileName As Variant, _
ByRef ImageData As Variant, ByRef DataLength As Variant) As Boolean
On Error GoTo ErrHandler
Dim bData() As Byte
Dim lFilSize As Long
Open sFileName For Binary Access Read As #1
lFilSize = LOF(1)
ReDim bData(lFilSize) As Byte
Dim i As Integer
i = 0
While i <= lFilSize
Get #1, i + 1, bData(i)
i = i + 1
Wend
ImageData = bData()
DataLength = lFilSize
GetImageFile = True
ExitCall:
Close #1
Exit Function
ErrHandler:
'Log error here.
GoTo ExitCall
End Function