Ducis » 20.10.2003 (Пн) 13:14
Создай модуль класса CIniFile.cls, помести туда это:
Option Explicit
Private strInI As String
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
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
'Public Function CreateIni(strFile As String)
''создание нового ini-файла
'strInI = strFile
'End Function
Public Sub SetValue(strSection As String, strKey As String, strValue As String)
' запись значения в ini-файл
WritePrivateProfileString strSection, strKey, strValue, strInI
End Sub
Public Function GetValue(strSection As String, strKey As String) As String
' получить значение из ini-файла
Dim strTmp As String
Dim lngRet As String
strTmp = String$(100, 0)
lngRet = GetPrivateProfileString(strSection, strKey, "", strTmp, Len(strTmp), strInI)
GetValue = Left(strTmp, lngRet)
End Function
Public Property Let INIFile(ByVal New_IniPath As String)
strInI = New_IniPath
End Property
Public Property Get INIFile() As String
INIFile = strInI
End Property
В проге делай так:
Dim INIFile As CIniFile
Set INIFile = New CIniFile
INIFile.INIFile = strFileName
'пишем значение ключа
INIFile.SetValue "GENERAL", "Key Name", "Key Value"
'читаем значение ключа
Dim strVar As String
strVar = INIFile.GetValue("GENERAL", "Key Name")
'заметаем следы
Set INIFile = Nothing
Понимаешь? (с)Б.Ельцин.