Dette tip viser, hvordan du kan bruge .ini filer, til at sætte eller læse fra.
***********************************************
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 Any, ByVal lpFileName As String) As Long
Public Function ReadIni(sSectHeader As String, sVarName As String, sFileName As String) As String
Dim strReturn As String
strReturn = String(255, Chr(0))
ReadIni = Left$(strReturn, GetPrivateProfileString(sSectHeader, ByVal sVarName, "", strReturn, Len(strReturn), sFileName))
End Function
Public Function WriteIni(sSectHeader As String, sVarName As String, sValue As String, sFileName As String) As Integer
WriteIni = WritePrivateProfileString(sSectHeader, sVarName, sValue, sFileName)
End Function
Private Sub Command1_Click()
Label1.Caption = ReadIni("Mail", "MAPI", "c:\winnt\win.ini")
End Sub
|