AtomWare
Messages postés71Date d'inscriptionsamedi 28 décembre 2002StatutMembreDernière intervention11 novembre 2004
-
5 mars 2003 à 19:40
cs_cyrilp
Messages postés140Date d'inscriptionmercredi 4 octobre 2000StatutMembreDernière intervention12 août 2009
-
6 mars 2003 à 21:42
Cette discussion concerne un article du site. Pour la consulter dans son contexte d'origine, cliquez sur le lien ci-dessous.
cs_cyrilp
Messages postés140Date d'inscriptionmercredi 4 octobre 2000StatutMembreDernière intervention12 août 2009 6 mars 2003 à 21:42
Mouais, ça sert à rien du tout... Je vais bientot poster un vieux code source que j'avais fait... DLL/ActiveX pour écrire/lire un fichier INI... Pratique et indispensable pour des dev impec' ;)
cs_BLU
Messages postés16Date d'inscriptionjeudi 11 juillet 2002StatutMembreDernière intervention31 juillet 2008 6 mars 2003 à 20:52
Essaie plutôt ce code là :
'API Lecture/Ecriture dans fichier INI
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 Declare Function WritePrivateProfileString Lib "kernel32" Alias "WritePrivateProfileStringA" (ByVal as_Section As String, ByVal aa_Key As Any, ByVal aa_NewValue As Any, ByVal as_IniFile As String) As Long
Public Enum IO_Ini
IniRead = 1
IniWrite = 2
End Enum
Public Function fx_IOFromIni(as_Section As String, as_Key As String, Optional av_WriteValue As String, Optional as_IniFile As String, Optional as_IOIni As IO_Ini) As String
Dim ls_StringRead As String
Select Case as_IOIni
Case IniRead
'Récupérer des variables dans un fichier INI
ls_StringRead = String(255, Chr(0))
fx_IOFromIni = Left(ls_StringRead, GetPrivateProfileString(as_Section, as_Key, "", ls_StringRead, Len(ls_StringRead), as_IniFile))
Case IniWrite
'Ecriture des variables dans un fichier INI
WritePrivateProfileString as_Section, as_Key, av_WriteValue, as_IniFile
End Select
End Function
EvilGost
Messages postés235Date d'inscriptionlundi 16 décembre 2002StatutMembreDernière intervention16 mai 20112 6 mars 2003 à 15:02
bon bah y a rien à rajouter , tout à été dit. Quant aux fichiers .ini, il y a ce qui faut sur vbfrance :)
MangaII
Messages postés129Date d'inscriptiondimanche 9 décembre 2001StatutMembreDernière intervention12 janvier 2009 6 mars 2003 à 10:17
C clair que ce code ne sert pas a grand chose ! a part écrire des lignes dans un fichier qquelconque. En plus, si tu écris dans un fichier qui existe déjà, il efface sont contenu précédent.
Si tu cherche à utiliser les fichiers INI, y'a des supers fonctions dans l'API de windows (spécialement pour les ini)
GetPrivateProfileString, et WritePrivateProfilString.
AtomWare
Messages postés71Date d'inscriptionsamedi 28 décembre 2002StatutMembreDernière intervention11 novembre 2004 5 mars 2003 à 19:40
Ton code n'est pas pour ecrire dans les ini, surtout que ca gère pas les sections, clés avec valeurs. Et a la fin, il faut metre var1 = text1.text, et var2 = text2.text, sinon, ce sont les textbox qui prennent la valeur des 2 variables. Et puis, c'est pas très clair ton exemple. Un 7 sur 10 ( Il y'a un temps ou je cherchais je genre de choses et ca m'etait utile )
6 mars 2003 à 21:42
6 mars 2003 à 20:52
'API Lecture/Ecriture dans fichier INI
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 Declare Function WritePrivateProfileString Lib "kernel32" Alias "WritePrivateProfileStringA" (ByVal as_Section As String, ByVal aa_Key As Any, ByVal aa_NewValue As Any, ByVal as_IniFile As String) As Long
Public Enum IO_Ini
IniRead = 1
IniWrite = 2
End Enum
Public Function fx_IOFromIni(as_Section As String, as_Key As String, Optional av_WriteValue As String, Optional as_IniFile As String, Optional as_IOIni As IO_Ini) As String
Dim ls_StringRead As String
Select Case as_IOIni
Case IniRead
'Récupérer des variables dans un fichier INI
ls_StringRead = String(255, Chr(0))
fx_IOFromIni = Left(ls_StringRead, GetPrivateProfileString(as_Section, as_Key, "", ls_StringRead, Len(ls_StringRead), as_IniFile))
Case IniWrite
'Ecriture des variables dans un fichier INI
WritePrivateProfileString as_Section, as_Key, av_WriteValue, as_IniFile
End Select
End Function
6 mars 2003 à 15:02
6 mars 2003 à 10:17
Si tu cherche à utiliser les fichiers INI, y'a des supers fonctions dans l'API de windows (spécialement pour les ini)
GetPrivateProfileString, et WritePrivateProfilString.
5 mars 2003 à 19:40