Lister toutes les cles d'une section d'un Fichier Ini [vb2008]
matheonimbus30
Messages postés60Date d'inscriptionvendredi 19 septembre 2008StatutMembreDernière intervention11 avril 2012
-
18 juin 2010 à 10:37
Utilisateur anonyme -
18 juin 2010 à 18:30
Bonjour,
J'ai trouvé ce code pour lire les cles d'une section d'un fichier ini sur codyx :
Friend Function GetPrivateProfileSection(ByVal lpAppName As String, ByVal lpReturnedString As IntPtr, ByVal nSize As Integer, ByVal lpFileName As String) As Integer
End Function
Public Function EnumIniKeys(ByVal IniPath As String, ByVal Section As String) As String()
Dim pBuffer As IntPtr = Marshal.AllocHGlobal(32768)
Dim keys() As String = Nothing
Try
Dim iRet As Integer = GetPrivateProfileSection(Section, pBuffer, 32768, IniPath)
If (iRet > 0) Then
Dim sReturned As String = Marshal.PtrToStringAnsi(pBuffer, iRet - 1)
keys = sReturned.Split(vbNullChar.ToCharArray(), StringSplitOptions.RemoveEmptyEntries)
If (keys IsNot Nothing AndAlso keys.Length > 0) Then
For i As Integer = 0 To keys.Length - 1
keys(i) = keys(i).Substring(0, keys(i).IndexOf("="))
Next
End If
Else
Return Nothing
End If
Catch ex As Exception
Finally
If pBuffer <> IntPtr.Zero Then
Marshal.FreeCoTaskMem(pBuffer)
End If
End Try
Return keys
End Function
Mais étant débutant en vb2008, je ne sais pas comment lister toutes les cles dans un combobox, c'est pourquoi je demande de l'aide.
Merci d'avance a+
A voir également:
Lister toutes les cles d'une section d'un Fichier Ini [vb2008]