SECTIONS READING

SECTIONS READING

Postby Silvio.Falconi » Fri Jun 30, 2023 7:56 am

I must read the sections of a ini file
I not understtod why it not load the sections

I made

Code: Select all  Expand view

 local cIniFilter  := triM(cFilePath( GetModuleFileName( GetInstance() ) )  + "test" +".ini")
   local aFilters    := GETPVPROFSECTIONS( cIniFilter )

STATIC FUNCTION GETPVPROFSECTIONS( cIni )
        LOCAL cBuf := SPACE( 65536 )
        LOCAL aSec := {}
        GETPRIVATEPROFILESECTIONNAMES( cBuf, 65536, cIni )
        WHILE LEFT( cBuf, 1 ) != CHR( 0 )
            AADD( aSec, LEFT( cBuf, AT( CHR( 0 ), cBuf ) - 1 ) )
            cBuf = SUBSTR( cBuf, AT( CHR( 0 ), cBuf ) + 1 )
        ENDDO
        RETURN aSec


 DLL STATIC FUNCTION GETPRIVATEPROFILESECTIONNAMES( cRetBuf AS LPSTR, nSize AS LONG, cFileName AS LPSTR ) AS DWORD;
        PASCAL FROM "GetPrivateProfileSectionNamesA" LIB "kernel32.dll"
 


refer.
https://learn.microsoft.com/en-us/windows/win32/api/winbase/nf-winbase-getprivateprofilesectionnames
Not run on Windows 7/10 ?
Since from 1991/1992 ( fw for clipper Rel. 14.4 - Momos)
I use : FiveWin for Harbour November 2023 - January 2024 - Harbour 3.2.0dev (harbour_bcc770_32_20240309) - Bcc7.70 - xMate ver. 1.15.3 - PellesC - mail: silvio[dot]falconi[at]gmail[dot]com
User avatar
Silvio.Falconi
 
Posts: 7033
Joined: Thu Oct 18, 2012 7:17 pm

Re: SECTIONS READING

Postby Detlef » Tue Jul 04, 2023 8:32 pm

Hi Silvio,
try this to get all section names of an ini file
Code: Select all  Expand view
#include "fivewin.ch"
#include "xbrowse.ch"

FUNCTION Main()
local cFile := CurDrive() + ":\" + curdir() + "\test.ini"
local aSections  := {}
local cLine
local oText
local n, nLines


   if File( cFile )
      oText  := TTxtFile():New( cFile )
      nLines := oText:RecCount()

      for n := 1 to nLines
          cLine := ltrim( oText:ReadLine() )

          if left( cLine, 1 ) == "
["
            aadd( aSections, cLine )
          endif

          oText:Skip()
      NEXT n

      oText:Close()
   endif

   if len( aSections ) > 0
      xBrowser aSections
   endif
RETURN nil

Regards
Detlef
User avatar
Detlef
 
Posts: 207
Joined: Mon Feb 07, 2022 9:54 pm

Re: SECTIONS READING

Postby Detlef » Tue Jul 04, 2023 8:34 pm

User avatar
Detlef
 
Posts: 207
Joined: Mon Feb 07, 2022 9:54 pm

Re: SECTIONS READING

Postby Silvio.Falconi » Wed Jul 05, 2023 7:50 am



I used that function's Emg
Since from 1991/1992 ( fw for clipper Rel. 14.4 - Momos)
I use : FiveWin for Harbour November 2023 - January 2024 - Harbour 3.2.0dev (harbour_bcc770_32_20240309) - Bcc7.70 - xMate ver. 1.15.3 - PellesC - mail: silvio[dot]falconi[at]gmail[dot]com
User avatar
Silvio.Falconi
 
Posts: 7033
Joined: Thu Oct 18, 2012 7:17 pm


Return to FiveWin for Harbour/xHarbour

Who is online

Users browsing this forum: Google [Bot] and 52 guests