'功能:从Ini中读取指定信息,INI文件要指明路径
'参数:optDefaultReturn,如果读到的值为空,则返回此默认值
'特别说明:有时为了对齐排版格式的需要,如文件:炭化室状态.txt,会在等号左右添加一些空格,测试发现,ReadINI会忽略掉这些空格,这是 GetPrivateProfileString API函数决定的,可理解为trim$(Key)后读取 和 trim$(返回值)再返回
' 如果值中前后本身就有空格,正常也会过滤掉,所以为了保证读取到值中固有的空格,存键值时(WriteIni)在值前后会加上单引号,而读取时会自动忽略掉前后的单引号,无需再多余处理
'实例:Print ReadINI("WQMInfo", "BMF", "E:\DoCin\WQM.ini")
Public Function ReadINI(Section, key, FileName, Optional optDefaultReturn = "") As String
Dim buff1 As String '一定要有此语句,否则返回为空值
buff1 = String$(65534, Chr$(0)) '最长键值长度
If Left$(Section, 1) = "[" And Right$(Section, 1) = "]" Then
Section = Mid$(Section, 2, Len(Section) - 2)
End If
GetPrivateProfileString Se