I managed to get all the section names as well as the items under them using this that I wrote when I payed attention to how the SectionName API command was being used.<br><br><FONT FACE=monospace><br>Public Sub ReadData()<br> Dim strSections As String<br> Dim lngSize As Long<br> Dim astrSections As Variant<br> Dim astrItems As Variant<br> Dim i As Integer<br> Dim Items As Variant<br><br> On Error GoTo HandleErrors<br> Form1.Label1.Caption = ""<br> ' In most cases, 1024 characters is enough, but if it's<br> ' not, the code will double that and try again.<br> lngSize = 1024<br> Do<br> strSections = Space$(lngSize)<br> lngSize = GetPrivateProfileSectionNames(strSections, lngSize, "C:\kbstuff\inistuff\Test.ini"

<br> If lngSize = 0 Then<br> ' No sections, so get out of here!<br> GoTo ExitHere<br> ElseIf lngSize = Len(strSections) - 2 Then<br> ' That's how the API indicates you didn't allow<br> ' enough space, but returning the size you originally<br> ' specified, less 2. In that case, just double the<br> ' buffer, and try again.<br> lngSize = lngSize * 2<br> Else<br> ' Trim the extra stuff. Use lngSize - 1 because<br> ' there's an extra vbNullChar at the end of this<br> ' string.<br> strSections = Left$(strSections, lngSize - 1)<br> Exit Do<br> End If<br> Loop<br> ' Now strSections contains the section names, separated<br> ' with vbNullChar.<br> astrSections = Split(strSections, vbNullChar)<br> For i = LBound(astrSections) To UBound(astrSections) - 1<br> ' Add the section to the collection, indicating that<br> ' it's not a NEW section. That is, it's not being added<br> ' after the file was read. That way, the code there can<br> ' know to not bother looking for items when being added<br> ' by code later.<br> <br> Form1.Label1.Caption = Form1.Label1.Caption & astrSections(i) & vbCrLf<br> astrItems = GetValues(astrSections(i))<br> For Each Items In astrItems<br> Form1.Label1.Caption = Form1.Label1.Caption & " " & Items & vbCrLf<br> Next<br> <br> 'Call AddSection(astrSections(i), False)<br> Next i<br><br>ExitHere:<br> Exit Sub<br><br>HandleErrors:<br> Err.Raise Err.Number, Err.Source, Err.Description<br>End Sub<br><br><br>Public Function GetValues(section As Variant) As Variant<br> Dim strSections As String<br> Dim lngSize As Long<br> Dim astrSections As Variant<br> Dim i As Integer<br><br> On Error GoTo HandleErrors<br><br> ' In most cases, 1024 characters is enough, but if it's<br> ' not, the code will double that and try again.<br> lngSize = 1024<br> Do<br> strSections = Space$(lngSize)<br> lngSize = GetPrivateProfileSection(section, strSections, lngSize, "C:\kbstuff\inistuff\Test.ini"

<br> If lngSize = 0 Then<br> ' No sections, so get out of here!<br> GoTo ExitHere<br> ElseIf lngSize = Len(strSections) - 2 Then<br> ' That's how the API indicates you didn't allow<br> ' enough space, but returning the size you originally<br> ' specified, less 2. In that case, just double the<br> ' buffer, and try again.<br> lngSize = lngSize * 2<br> Else<br> ' Trim the extra stuff. Use lngSize - 1 because<br> ' there's an extra vbNullChar at the end of this<br> ' string.<br> strSections = Left$(strSections, lngSize - 1)<br> Exit Do<br> End If<br> Loop<br> ' Now strSections contains the section names, separated<br> ' with vbNullChar.<br> astrSections = Split(strSections, vbNullChar)<br> <br> GetValues = astrSections<br> <br>ExitHere:<br> Exit Function<br><br>HandleErrors:<br> Err.Raise Err.Number, Err.Source, Err.Description<br>End Function<br><br></font> <p>Karl<br><a href=mailto:kb244@kb244.8m.com>kb244@kb244.8m.com</a><br><a href=
</a><br>Experienced in , or have messed with : VC++, Borland C++ Builder, VJ++6(starting),VB-Dos, VB1 thru VB6, Delphi 3 pro, Borland C++ 3(DOS), Borland C++ 4.5, HTML,Visual InterDev 6, ASP(WebProgramming), QBasic(least i didnt start with COBOL)