I wonder whether there exists a function to get the keys under a section of an .ini registry file, something like RegGetSubkeys for registries. If this is not the case, I would kindly ask for any comments on such a function that I have written for my own needs. Many thanks in advance.
Function GetRegSection
Function GetRegSection
function# $IniFile $Section ARRAY(str)&a
;Keys under a section in .ini file
;Example
;str sf="$my qm$\Files\Registry\RegAFJCat.ini"
;str sec="other"
;ARRAY(str) a
;if(GetRegSection(sf sec a))
,;out "Error in Registry File"
,;ret
;for int'i 0 a.len
,;out a[i]
,
str sr.getfile(IniFile)
str pat=F"[^]?[\r\n]?\[\\\Q{Section}\E\][\r\n]"
int resui
int istrt=findrx(sr pat 0 0 resui)
if istrt<0
,ret 1
resui=resui+1
int iend=findrx(sr "[\r\n^]\[\\.+?\][\r\n]" istrt+3)
str st
if iend > istrt
,st.get(sr istrt+resui iend-istrt-resui)
else
,st.get(sr istrt+resui)
st.ToUnicode
str sl
foreach sl st
,sl.trim
,if empty(sl); continue
,a[]=sl
ret 0