zinimgmt.bas

来自「快速数据库的编程实现」· BAS 代码 · 共 38 行

BAS
38
字号
Attribute VB_Name = "INIMgmt"
Private Const sizer = 255 * 5 'should be adequate b/c for 4 (255 char) fields and 1 extra to store bytes and tombstone word
Private Declare Function GetPrivateProfileString Lib "kernel32" Alias "GetPrivateProfileStringA" (ByVal lpApplicationName As String, ByVal lpKeyName As Any, ByVal lpDefault As String, ByVal lpReturnedString As String, ByVal nSize As Long, ByVal lpFileName As String) As Long
Private Declare Function WritePrivateProfileString Lib "kernel32" Alias "WritePrivateProfileStringA" (ByVal lpApplicationName As String, ByVal lpKeyName As Any, ByVal lpString As Any, ByVal lpFileName As String) As Long

Public Function ReadIndex(ByVal lstrKey As String) As String
On Error Resume Next
Dim lfixedstrRetValue As String * sizer
Dim lstrRetValue As String
Dim lintJunk As Integer
Dim lstrSection As String
    
    lstrSection = "Index"
    lfixedstrRetValue = String(sizer, " ")
    lintJunk = GetPrivateProfileString(lstrSection, lstrKey, " ", lfixedstrRetValue, sizer, IndexPath)
    lstrRetValue = Trim(lfixedstrRetValue)
    lstrRetValue = Left(lstrRetValue, Len(lstrRetValue) - 1)
    ReadIndex = lstrRetValue

On Error GoTo 0
On Error Resume Next
End Function


Public Sub WriteIndex(ByVal lstrKey As String, ByVal lstrValue As String)
On Error Resume Next
Dim lstrSection As String
Dim lintJunk As Integer
    
    lstrSection = "Index"
    lstrValue = Trim(lstrValue)
    lintJunk = WritePrivateProfileString(lstrSection, lstrKey, lstrValue, IndexPath)
    
    On Error GoTo 0
    On Error Resume Next
End Sub

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?