#include <_ini.au3> ;_IniWrite()添加一行;_IniDelete()删除一行;_IniWriteSection()二维数组写入某字段;_IniRead()读取一行
#include <Array.au3>
$sIniFile = @ScriptDir & "\Config.ini" ;'='分隔关键字的配置文件
$sIniFile1 = @ScriptDir & "\Config_1.ini" ;'|'分隔关键字的配置文件
$Section = 'FastStart'
$slist1 = __IniReadToArray_fz($sIniFile, $Section) ;, $sDecimal) ;仿照afan老师的__IniReadToArray
_ArrayDisplay($slist1, 'fz')
$slist2 = __IniReadToArray($sIniFile1, $Section) ;, $sDecimal = '|') ;afan老师特编的函数
_ArrayDisplay($slist2, 'afan')
;===================读标准ini文件(键值中以'|'分隔)到二维数组及填充listview的函数,系根据afan老师的__IniReadToArray这个函数自编的=================
Func __IniReadToArray_fz($sIniFile, $Section, $sDecimal = '|')
$aList = _IniReadSection($sIniFile, $Section) ;, $mode = 0) ;读取整个字段内容
Local $i = 1
Local $aLine[UBound($aList)]
For $i = 1 to UBound($aList) - 1
$aLine[$i - 1] = $aList[$i][0] & $sDecimal & $aList[$i][1]
Next
$aLine == _ArrayDelete($aLine, UBound($aLine) - 1) ;删除最后一个空行
_ArrayDisplay($aLine, '$aLine') ;截止这里与与afan老师的函数显示结果一样
;If @error Then Return SetError(1)
Local $i, $afg, $j, $iMax = 1, $iC = 1
Local $aData[UBound($aLine)][$iMax]
For $i = 0 To UBound($aLine) - 1
$afg = StringSplit($aLine[$i], $sDecimal, 1)
For $j = 1 To $afg[0]
If $afg[0] > $iMax Then
$iMax = $afg[0]
ReDim $aData[UBound($aData)][$iMax]
EndIf
$aData[$i][$j - 1] = $afg[$j]
Next
Next
ReDim $aData[UBound($aData)][$iMax]
Return $aData
EndFunc ;==>__IniReadToArray__fz
;===================读'|'分隔符非标准ini文件成二维数组的函数 afan编写==================================
Func __IniReadToArray($sIniFile, $Section, $sDecimal = '|')
;ini文件路径 ;字段名 ;分隔符
Local $sIni = FileRead($sIniFile)
Local $_Section = StringRegExpReplace($Section, '^\h*(.+?)\h*, '$1')
$_Section = StringRegExpReplace($_Section, '(\.|\||\*|\?|\+|\(|\)|\{|\}|\[|\]|\^|\$|\\)', '\\$1')
$sIni = StringRegExpReplace($sIni, '(?mi)[\s\S]*?^\h*\[' & $_Section & '\]\V*\v+([\s\S]+?)(?=\r\n\h*\[|\z)[\s\S]*', '\1')
Local $aLine = StringRegExp($sIni, '\V+', 3)
_ArrayDisplay($aLine, '$aLine') ;截止这里显示的结果与仿照函数结果一样
If @error Then Return SetError(1)
Local $i, $afg, $j, $iMax = 1, $iC = 1
Local $aData[UBound($aLine)][$iMax]
For $i = 0 To UBound($aLine) - 1
$afg = StringSplit($aLine[$i], $sDecimal, 1)
For $j = 1 To $afg[0]
If $afg[0] > $iMax Then
$iMax = $afg[0]
ReDim $aData[UBound($aData)][$iMax]
EndIf
$aData[$i][$j - 1] = $afg[$j]
Next
Next
ReDim $aData[UBound($aData)][$iMax]
Return $aData
EndFunc ;==>__IniReadToArray
标准ini式样: