cBinaryFile.cls
资源名称:IE_VB.rar [点击查看]
上传用户:davilee3
上传日期:2015-04-22
资源大小:986k
文件大小:3k
源码类别:
浏览器
开发平台:
Visual Basic
- VERSION 1.0 CLASS
- BEGIN
- MultiUse = -1 'True
- Persistable = 0 'NotPersistable
- DataBindingBehavior = 0 'vbNone
- DataSourceBehavior = 0 'vbNone
- MTSTransactionMode = 0 'NotAnMTSObject
- END
- Attribute VB_Name = "cBinaryFile"
- Attribute VB_GlobalNameSpace = False
- Attribute VB_Creatable = True
- Attribute VB_PredeclaredId = False
- Attribute VB_Exposed = False
- Attribute VB_Ext_KEY = "SavedWithClassBuilder6" ,"Yes"
- Attribute VB_Ext_KEY = "Top_Level" ,"Yes"
- Option Explicit
- Private mFn As Long
- Private mOpened As Boolean
- Public Function OpenFile(nFile As String) As Boolean
- mFn = FreeFile
- Open nFile For Binary As mFn
- mOpened = True
- End Function
- Public Function CloseFile() As Boolean
- If mOpened Then
- Close mFn
- End If
- End Function
- Public Function WriteStringLng(nStr As String) As Boolean
- Dim tLen&
- If mOpened Then
- tLen = LenB(StrConv(nStr, vbFromUnicode))
- Put mFn, , tLen
- Put mFn, , nStr
- End If
- End Function
- Public Function ReadStringLng(nStr As String) As Boolean
- Dim tLen&
- If mOpened Then
- Get mFn, , tLen
- nStr = StrConv(InputB(tLen, mFn), vbUnicode)
- End If
- End Function
- Public Function WriteStringInt(nStr As String) As Boolean
- Dim tLen%
- If mOpened Then
- tLen = LenB(StrConv(nStr, vbFromUnicode))
- Put mFn, , tLen
- Put mFn, , nStr
- End If
- End Function
- Public Function ReadStringInt(nStr As String) As Boolean
- Dim tLen%
- If mOpened Then
- Get mFn, , tLen
- nStr = StrConv(InputB(tLen, mFn), vbUnicode)
- End If
- End Function
- Public Function GetStringInt() As String
- Dim tLen%, rtn$
- If mOpened Then
- Get mFn, , tLen
- rtn = StrConv(InputB(tLen, mFn), vbUnicode)
- End If
- GetStringInt = rtn
- End Function
- Public Function WriteStringByt(nStr As String) As Boolean
- Dim tLen As Byte
- If mOpened Then
- tLen = LenB(StrConv(nStr, vbFromUnicode))
- Put mFn, , tLen
- Put mFn, , nStr
- End If
- End Function
- Public Function ReadStringLngByt(nStr As String) As Boolean
- Dim tLen As Byte
- If mOpened Then
- Get mFn, , tLen
- nStr = StrConv(InputB(tLen, mFn), vbUnicode)
- End If
- End Function
- Public Function PutLng(nVal As Long) As Boolean
- If mOpened Then
- Put mFn, , nVal
- End If
- End Function
- Public Function GetLng() As Long
- Dim tVal&
- If mOpened Then
- Get mFn, , tVal
- End If
- GetLng = tVal
- End Function
- Public Function PutByte(nVal As Byte) As Boolean
- If mOpened Then
- Put mFn, , nVal
- End If
- End Function
- Public Function GetByte() As Byte
- Dim tVal As Byte
- If mOpened Then
- Get mFn, , tVal
- End If
- GetByte = tVal
- End Function
- Public Function GetFileNumber()
- GetFileNumber = mFn
- End Function
- Private Sub Class_Initialize()
- mOpened = False
- End Sub
- Private Sub Class_Terminate()
- Call CloseFile
- End Sub