0
好吧,所以我有这些功能,我通过我的vba代码使用。 这可能就像vbs一样。阅读整个ini部分,并将其放入数组
这里的功能(S)
'declarations for working with Ini files
Private Declare Function GetPrivateProfileSection Lib "kernel32" Alias _
"GetPrivateProfileSectionA" (ByVal lpAppName As String, ByVal lpReturnedString As String, _
ByVal nSize As Long, ByVal lpFileName As String) As Long
Private Declare Function GetPrivateProfileString Lib "kernel32" Alias _
"GetPrivateProfileStringA" (ByVal lpApplicationName As String, ByVal lpKeyName As Any, _
ByVal lpDefault As String, ByVal lpReturnedString As String, ByVal nSize As Long, _
ByVal lpFileName As String) As Long
'// INI CONTROLLING PROCEDURES
'reads an Ini string
Public Function ReadIni(Filename As String, Section As String, Key As String) As String
Dim RetVal As String * 255, v As Long
v = GetPrivateProfileString(Section, Key, "", RetVal, 255, Filename)
ReadIni = Left(RetVal, v + 0)
End Function
'reads an Ini section
Public Function ReadIniSection(Filename As String, Section As String) As String
Dim RetVal As String * 255, v As Long
v = GetPrivateProfileSection(Section, RetVal, 255, Filename)
ReadIniSection = Left(RetVal, v + 0)
End Function
如何使用它来创建一个功能,基本上可以让我只指定部分,我想看看在,然后找到该板块内的每个INI串并将其放入一个数组并返回该数组,以便我可以使用它进行循环?
编辑:我看到ReadIniSection返回一个巨大的字符串中的所有键。 意思是说,我需要把它分开。
ReadIniSection返回的东西看起来像这样: “Fornavn = FORNAVN [] Etternavn = ETTERNAVN”等等等等。中间的[]没有括号,它是一个正方形。可能有些字符不能识别。所以我想我应该通过一个拆分命令来运行它,该命令采用a =和方块之间的值。
看起来不错!太好了谢谢! :) – 2011-03-29 12:06:20