spectresombre
Messages postés22Date d'inscriptionmardi 28 janvier 2003StatutMembreDernière intervention26 août 2003
-
14 févr. 2003 à 18:10
spectresombre
Messages postés22Date d'inscriptionmardi 28 janvier 2003StatutMembreDernière intervention26 août 2003
-
15 févr. 2003 à 17:09
Salut,
Aucun souci pour écrire dans un fichier ini mais pour la lecture : IMPOSSIBLE!!!
Mon module se présente comme ceci :
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
Function LireINI(Entete As String, Variable As String) As String
Dim strRetour As String
Fichier = App.Path & "" & App.EXEName & ".ini"
strRetour = String(255, Chr(0))
Dim Longueur As Integer
Longueur = GetPrivateProfileString(Entete, Variable, "", strRetour, Len(strRetour), Fichier)
LireINI = Left$(strRetour, Longueur)
End Function
Function EcrireINI(Entete As String, Variable As String, Valeur As String) As String
Fichier = App.Path & "" & App.EXEName & ".ini"
EcrireINI = WritePrivateProfileString(Entete, Variable, Valeur, Fichier)
End Function
La variable "Longueur" est reste à 0 alors ke mon fichier ini nest pas vide.
La fonction LireINI reste vide.
Quelqu'un saurait-il m'aider?
Merci beaucoup d'avance
TheSaib
Messages postés2367Date d'inscriptionmardi 17 avril 2001StatutMembreDernière intervention26 décembre 200723 15 févr. 2003 à 16:11
Je l'ai testé comme çà :
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
Function LireINI(Entete As String, Variable As String) As String
Dim strRetour As String
Fichier = App.Path & "" & App.EXEName & ".ini"
strRetour = String(255, Chr(0))
Dim Longueur As Integer
Longueur = GetPrivateProfileString(Entete, Variable, "", strRetour, Len(strRetour), Fichier)
LireINI = Left$(strRetour, Longueur)
End Function
Function EcrireINI(Entete As String, Variable As String, Valeur As String) As String
Fichier = App.Path & "" & App.EXEName & ".ini"
EcrireINI = WritePrivateProfileString(Entete, Variable, Valeur, Fichier)
End Function
Private Sub Command1_Click()
Call EcrireINI("test", "ptout", "prout")
MsgBox LireINI("test", "ptout")
End Sub