07-24-2012, 02:51 PM
Macro Macro1793
out
;---------------
;create ini file for testing
str lines=
;[config1]
;abc
;
;[config2]
;cde=1
;fgh=2
;ijk=3
;
;[config3]
;etc...
str iniFile.expandpath("$temp$\qm48825.ini")
lines.setfile(iniFile)
;---------------
str var_config="config2"
str x
int nSize=100*1024; x.all(nSize)
x.fix(GetPrivateProfileSection(var_config x nSize iniFile))
if x.len
,;GetPrivateProfileSection returns multistring; show each string
,lpstr s=x
,rep
,,if(!s[0]) break
,,out s
,,s+len(s)+1
else out "not found"
;this is not perfect code. 1. Need to ensure that nSize is big enough; 2. Need to use Unicode function version to support Unicode in ini file path.