CODE
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
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 Ret As String
Public Sub WriteINI(filename As String, Section As String, Key As String, Text As String)
WritePrivateProfileString Section, Key, Text, filename
End Sub
Public Function ReadINI(filename As String, Section As String, Key As String)
Ret = Space$(255)
RetLen = GetPrivateProfileString(Section, Key, "", Ret, Len(Ret), filename)
Ret = Left$(Ret, RetLen)
ReadINI = Ret
End Function
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 Ret As String
Public Sub WriteINI(filename As String, Section As String, Key As String, Text As String)
WritePrivateProfileString Section, Key, Text, filename
End Sub
Public Function ReadINI(filename As String, Section As String, Key As String)
Ret = Space$(255)
RetLen = GetPrivateProfileString(Section, Key, "", Ret, Len(Ret), filename)
Ret = Left$(Ret, RetLen)
ReadINI = Ret
End Function
No form:
pra gravar:
'altere o caminho da pasta onde quer gravar o arquivo
CODE
WriteINI "c:\windows\conf.ini", "teste", "teste", text1
pra ler:
CODE
text1 = ReadINI("C:\Windows\conf.ini", "teste", "teste")