Feedback

INI Werte enumerieren

Sprache: VB

Alle Werte einer INI Sektion enumerieren (aufzählen) und in einem Array speichern
Private Declare Ansi Function GetPrivateProfileSectionNames Lib "kernel32" Alias "GetPrivateProfileSectionNamesA" ( _
    ByVal lpszReturnBuffer() As Byte, _
    ByVal nSize As Integer, ByVal _
    lpFileName As String) _
As Integer

Public Function GetSectionNames(ByVal INIFile As String) As String()
    Dim Buffer(32768) As Byte
    GetPrivateProfileSectionNames(Buffer, 32768, INIFile)
    Dim Sections() As String = System.Text.Encoding.ASCII.GetString(Buffer).Trim(ControlChars.NullChar).Split(ControlChars.NullChar)
    Return Sections
End Function
Private Declare Ansi Function GetPrivateProfileSectionNames Lib "kernel32" Alias "GetPrivateProfileSectionNamesA" ( _
    ByVal lpszReturnBuffer() As Byte, _
    ByVal nSize As Integer, ByVal _
    lpFileName As String) _
As Integer

Public Function GetSectionNames(ByVal INIFile As String) As String()
    Dim Buffer(32768) As Byte
    GetPrivateProfileSectionNames(Buffer, 32768, INIFile)
    Dim Sections() As String = System.Text.Encoding.ASCII.GetString(Buffer).Trim(ControlChars.NullChar).Split(ControlChars.NullChar)
    Return Sections
End Function