使用adodb 实现的文件二进制存取工具, 后期会更新更多函数, 目前就2个
Option Explicit
' 作者:邓伟
' 网站:www.vb6.pro
' Library ADODB
'C: \Program Files (x86)\Common Files\System\ado\msado28.tlb
' Microsoft ActiveX Data Objects 2.8 Library
Public Inst As New ADODB.Stream
Public LastError As String
Public Function LoadFileAsBinary(ByVal Path As String, OutData() As Byte) As Boolean
On Error GoTo EH
LastError = ""
With Inst
If .State <> adStateClosed Then .Close
.Type = adTypeBinary
.Open
.LoadFromFile Path
OutData = .Read()
.Close
End With
LoadFileAsBinary = True
Exit Function
EH:
LastError = Err.Description & "#" & Err.Description
End Function
Public Function SaveFileAsBinary(ByVal Path As String, OutData() As Byte) As Boolean
On Error GoTo EH
LastError = ""
With Inst
If .State <> adStateClosed Then .Close
.Type = adTypeBinary
.Open
.Write OutData
.SaveToFile Path, adSaveCreateNotExist
.Close
End With
SaveFileAsBinary = True
Exit Function
EH:
LastError = Err.Description & "#" & Err.Description
End Function
Views: 61