visto che oggi sono buono
codice:
Public 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 ReadStringIni(ByVal sSection As String, ByVal sKeyName As String, ByVal sFileName As String) As String
'
' Legge una stringa da un file *.INI
' Input: sSection sezione
' sKeyName parola chiave
' sFileName file *.INI
' Output: stringa letta oppure "" se fallita lettura
'
Dim nResult As Integer
Dim sDefault As String
Dim sReturnedString As String
Dim nSize As Integer
On Error GoTo ReadStringIniError
sDefault = ""
sReturnedString = Space$(255)
nSize = 255
nResult = GetPrivateProfileString(sSection, sKeyName, sDefault, sReturnedString, nSize, sFileName)
If nResult <> 0 Then
ReadStringIni = Left$(sReturnedString, nResult)
Else
'errore
ReadStringIni = ""
End If
Exit Function
ReadStringIniError:
ReadStringIni = ""
End Function