Originariamente inviato da pasaran
esiste un'api apposta. Appena ho la possibilita' te la invio.
Permette di accedere sia in lettura che in scrittura direttamente all'elemento che ti interessa senza fare di volta in volta il ciclo di lettura del file .ini.codice: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 Function INIRead(File As String, Section As String, _ Item As String) As String Dim sBuf As String, iRC As Integer sBuf = Space(255) iRC = GetPrivateProfileString(Section, Item, "Not Found", sBuf, 255, File) sBuf = Left$(sBuf, iRC) If StrComp(sBuf, "Not Found") = 0 Then INIRead = vbNullString Else INIRead = sBuf End If End Function Public Sub INIWrite(File As String, Section As String, _ Item As String, ItemValue As String) WritePrivateProfileString Section, Item, ItemValue, File End Sub

Rispondi quotando