Option Compare Database

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 String, ByVal lpFileName As String) As Long

Public Function WriteINI(strAppName As String, strKeyName As String, strValueStr As String, strFileName As String) As Long
  WriteINI = WritePrivateProfileString(strAppName, strKeyName, strValueStr, strFileName)
End Function

Public Function GetINI(strAppName As String, strKeyName As String, strValueStr As String, strFileName As String) As String
Const STRING_SIZE = 255 '指定字符串?度
Dim lngLength As Long '定?API函?返回的?度
Dim strDefault As String * STRING_SIZE '定?在?有找到指定的?目?返回的默?值
Dim strReturn As String * STRING_SIZE '定?一?字符串???

lngLength = GetPrivateProfileString(strAppName, strKeyName, strDefault, strReturn, STRING_SIZE, strFileName)

If (lngLength = 0) Then
GetINI = strValueStr
Else
GetINI = Mid(strReturn, 1, lngLength)
End If

End Function

posted on 2005-01-19 09:15  James Wong   阅读(705)  评论(0)    收藏  举报