Check out the FAQs in this forum.
Here's a thread: faq222-1198
I haven't viewed this if it actually works but the API functions used will steer you in the right direction. [/b][/i][/u]*******************************************************[sub]
General remarks:
If this post contains any suggestions for the use or distribution of code, components or files of any sort, it is still your responsibility to assure that you have the proper license and distribution rights to do so!
Private Sub Form_Load()
iniPath = "c:\temp\temp.ini"
End Sub
Private Sub Command2_Click()
Call IniDetailsWrite("Section1", "Value1", "WrittenValue"
End Sub
Private Sub Command1_Click()
MsgBox IniDetailsRead("Section1", "Value1", "Section1Value1"
End Sub
'--------------
'In a module
Option Explicit
Dim sdata As String
Dim lDataLen
Public iniPath As String
Declare Function WritePrivateProfileString _
Lib "kernel32" Alias "WritePrivateProfileStringA" _
(ByVal lpApplicationName As String, ByVal _
lpKeyName As Any, ByVal lsString As Any, _
ByVal lplFilename As String) As Long
Declare Function GetPrivateProfileString Lib _
"kernel32" Alias "GetPrivateProfileStringA" _
(ByVal lpApplicationName As String, ByVal _
lpKeyName As String, ByVal lpDefault As _
String, ByVal lpReturnedString As String, _
ByVal nSize As Long, ByVal lpFileName As _
String) As Long
'Return ini information
Public Function IniDetailsRead(Section As String, Key As String, DefaultValue As String) As String
'you may want to use app.path as the default dir
sdata = Space$(500)
lDataLen = GetPrivateProfileString(Section, Key, DefaultValue, sdata, Len(sdata), iniPath)
IniDetailsRead = Trim(Left$(sdata, lDataLen))
End Function
Public Function IniDetailsWrite(Section As String, Key As String, NewValue As String)
' Set the string value.
Dim retval
retval = WritePrivateProfileString(Section, Key, NewValue, iniPath)
End Function
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.