Function ReadPrivateIni(strFileName AS String, _ strSection AS String, _ strHeader AS String) AS String Dim hFile AS HANDLE 'Dim cAllFileData[8192] AS char Dim Section AS String * 2048 Dim ptrSectionStart AS Long Dim ptrSectionFin AS Long Dim nStart AS Long Dim nFin AS ULONG Dim LineString AS STRING * 2048 Dim cAllFileData$ * (LOF(strFileName$) +1) hFile = Freefile OPEN strFileName$ FOR INPUT AS hFile WHILE NOT EOF(hFile) ' While we have not reached the End Of File LINE INPUT hFile, Section ' Read a line from the file Concat (cAllFileData$,Section$) Concat (cAllFileData$,$CRLF) WEND ' Loop until finished CLOSE hFile ' Close the file If Len(cAllFileData$) = 0 Then msgbox("Could not read INI File" & str$(LOF(strFileName$))) Function = "" End If 'Now get or Set Section Data Section$ = "[" & trim$(strSection$) & "]" nStart = instr(cAllFileData$,Section$,1,1) nFin = instr(cAllFileData$,"[",nStart + 4) If nFin = 0 then nFin = LOF(strFileName$) Section$ = Mid$( cAllFileData$,nStart,nFin - nStart) If nStart <> 0 Then ptrSectionStart = nStart ptrSectionFin = nFin Section$ = Mid$( cAllFileData$,nStart,nFin - nStart) nStart = instr(Section$,strHeader$,1,1) nFin = instr(Section$,CR$,nStart + 2,) If nStart <> 0 then 'now we need to replace the line with the new data LineString$ = Mid$(Section$,nStart,nFin - nStart) nStart = instr$(LineString$,"=") + 1 FUNCTION = Mid$(LineString$,nStart) End If End If Function = "" End Function