调用INI文件

Public Function IniFileRead(ByVal vstrINIPath As String, vstrINIFileName As String, _
    ByVal vstrINIType As String, ByRef vstrVar As String, ByVal vstrName As String) As Boolean
   
    On Error GoTo errHandler
    Dim lResult As Long
    Dim sTemp As String
    Dim lDB As Long
    Dim msIniFileFullPath As String
   
    IniFileRead = False
   
    msIniFileFullPath = vstrINIPath & "\" & vstrINIFileName

    'get connection string
    sTemp = Space$(300)
    lResult = GetPrivateProfileString(vstrINIType, _
                                      vstrName, _
                                      "", _
                                      sTemp, _
                                      300, _
                                      msIniFileFullPath)
   
    If lResult < 1 Or lResult > 300 Then
        GoTo errHandler
    Else
        sTemp = Left(sTemp, lResult)
    End If
    vstrVar = sTemp
   
    IniFileRead = True
   
    Exit Function
errHandler:
    IniFileRead = False
   
End Function

posted on 2006-07-01 21:18  kenty  阅读(346)  评论(0编辑  收藏  举报