Hay un evento (list value changed) que dispara un getvar() del módulo en cuestión, la primera vez que se ejecuta lo hace bien, las siguientes veces no lee nada. Pruebo putvar() y no funciona tampoco... os aseguro que con anterioridad yo he usado éstas funciones en éste mismo ordenador y no había problema, el código está comprobadisimo.
¿Es posible que con alguna última actualización haya cambiado el comportamiento de éstas? me parece muy raro, ya que sobre framework 4 en win7 funciona... no se... yo pienso que debería hacerle un exorcismo al pc o algo... ¿alguna idea? o ¿puede alguien probar el código en winxp y avisarme si funciona?
Código
Module modSystem Public Declare Function GetPrivateProfileString Lib "kernel32" Alias "GetPrivateProfileStringA" (ByVal AppName As String, ByVal KeyName As String, ByVal keydefault As String, ByVal ReturnedString As String, ByVal RSSize As Integer, ByVal FileName As String) As Integer Public Declare Function WritePrivateProfileString Lib "kernel32" Alias "WritePrivateProfileStringA" (ByVal AppName As String, ByVal KeyName As String, ByVal keydefault As String, ByVal FileName As String) As Integer Public Sub WriteINI(ByRef INISection As String, ByRef INIKey As String, ByRef INIValue As String, ByRef INIFile As String) Call WritePrivateProfileString(INISection, INIKey, INIValue, INIFile) End Sub Public Function ReadINI(ByRef Section As String, ByRef KeyName As String, ByRef FileName As String, ByRef Default_Renamed As String) As String Dim sRet As String sRet = New String(Chr(0), 255) ReadINI = Left(sRet, GetPrivateProfileString(Section, KeyName, Default_Renamed, sRet, Len(sRet), FileName)) End Function Dim sSpaces As String ' Max string length Dim szReturn As String ' Return default value if not found szReturn = vbNullString sSpaces = Space(5000) GetVar = RTrim(sSpaces) GetVar = Microsoft.VisualBasic.Strings.Left(GetVar, Len(GetVar) - 1) End Function Public Sub PutVar(ByRef file As String, ByRef Header As String, ByRef Var As String, ByRef Value As String) On Error GoTo PutVar_Error Dim fpath As String Call WritePrivateProfileString(Header, Var, Value, fpath) On Error GoTo 0 Exit Sub PutVar_Error: End Sub End Module