从ini文件读取的字符串如何连接

gavin_sw 2004-08-11 03:46:46
VB里面有个ini文件的读取函数Private Declare Function GetPrivateProfileString Lib "kernel32" Alias "GetPrivateProfileStringA" (ByVal lpApplicationName As String, ByVal lpKeyName As String, ByVal lpDefault As String, ByVal lpReturnedString As String, ByVal nSize As Int32, ByVal lpFileName As String) As Int32, 其中pReturnedString是读取的字符串,这个字符串怎么跟别的字符串连接?我读取4个KEY值,想把它们连接起来,结果只看到第一个字符串的值? 哪位大哥帮帮忙。。
...全文
100 点赞 收藏 3
写回复
3 条回复
切换为时间正序
当前发帖距今超过3年,不再开放新的回复
发表回复
guxingfeiyu 2004-08-11
简例:
Private Declare Function GetPrivateProfileString Lib "kernel32" Alias "GetPrivateProfileStringA" (ByVal lpApplicationName As String, ByVal lpKeyName As String, ByVal lpDefault As String, ByVal lpReturnedString As String, ByVal nSize As Long, ByVal lpFileName As String) As Long

Private Sub Command1_Click()
Dim strTmp1 As String * 260, strTmp2 As String * 260
Dim strTmp As String
Dim i As Long
'strTmp1 = Space(260)
'strTmp2 = Space(260)
i = GetPrivateProfileString("APP", "Key1", "", strTmp1, 260, "inifilename.ini")
strTmp = Left(strTmp1, i)
i = GetPrivateProfileString("APP", "Key2", "", strTmp2, 260, "inifilename.ini")
strTmp = strTmp & Left(strTmp2, i)
End Sub
回复
tommychim 2004-08-11
GetPrivateProfileSection strSection(i), strTemp, lngSize, OpenModule
Section名称 Ini文件
回复
tommychim 2004-08-11
用这个:
Public 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

Dim strTemp As String, lngSize As Long
Dim strKey() As String

lngSize = 32000
strTemp = Space(lngSize)
GetPrivateProfileSection strSection(i), strTemp, lngSize, OpenModule
strKey = Split(strTemp, vbNullChar)
For j = 0 To UBound(strKey) - 2
'处理
Next
回复
发帖
VB基础类
创建于2007-09-28

7479

社区成员

VB 基础类
申请成为版主
帖子事件
创建了帖子
2004-08-11 03:46
社区公告
暂无公告