⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 readini.bas

📁 VB6数据库开发指南》的配套源程序
💻 BAS
字号:
Attribute VB_Name = "INIFileReader"
Option Explicit

Const INI_SECTION = "Data Files"
Const INI_FILENAME = "VB5DBHT.INI"
Const MAX_PATH = 128

#If Win32 Then
    Declare Function GetPrivateProfileString _
        Lib "Kernel32" Alias "GetPrivateProfileStringA" (ByVal lpSectionName As String, _
        ByVal lpKeyName As Any, ByVal lpDefault As String, _
        ByVal strReturnedStringFixed As String, ByVal Size As Integer, _
        ByVal lpFileName As String) As Integer
#Else
    Declare Function GetPrivateProfileString _
        Lib "Kernel" (ByVal lpSectionName As String, _
        ByVal lpKeyName As Any, ByVal lpDefault As String, _
        ByVal strReturnedStringFixed As String, ByVal Size As Integer, _
        ByVal lpFileName As String) As Integer
#End If
    

Public Function strBiblioDb() As String
    ' Returns the fully qualiied path name to BIBLIO.MDB,
    ' as recorded in VBDBHT.INI.
    ' Returns an empty string if information is not found.
    
    Dim strReturnedStringFixed As String * MAX_PATH
    Dim intBytesBack As Integer
    
    intBytesBack = GetPrivateProfileString(INI_SECTION, _
        "BIBLIO", "", strReturnedStringFixed, MAX_PATH, INI_FILENAME)
    strBiblioDb = IIf(intBytesBack > 0, Left$(strReturnedStringFixed, intBytesBack), "")
    
End Function
Public Function strNWindDb() As String
    ' Returns the fully qualiied path name to NWIND.MDB,
    ' as recorded in VB5DBHT.INI.
    ' Returns an empty string if information is not found.
    
    Dim strReturnedStringFixed As String * MAX_PATH
    Dim intBytesBack As Integer
    
    intBytesBack = GetPrivateProfileString(INI_SECTION, _
        "NWIND", "", strReturnedStringFixed, MAX_PATH, INI_FILENAME)
    strNWindDb = IIf(intBytesBack > 0, Left$(strReturnedStringFixed, intBytesBack), "")
    
End Function


Public Function DataPath() As String
    ' Returns the top-level VBDBHT directory
    
    Dim strReturnedStringFixed As String * MAX_PATH
    Dim intBytesBack As Integer
    
    intBytesBack = GetPrivateProfileString(INI_SECTION, _
        "Data", "", strReturnedStringFixed, MAX_PATH, INI_FILENAME)
    DataPath = IIf(intBytesBack > 0, Left$(strReturnedStringFixed, intBytesBack), "")
    
End Function

⌨️ 快捷键说明

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