从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值,想把它们连接起来,结果只看到第一个字符串的值? 哪位大哥帮帮忙。。
...全文
171 3 打赏 收藏 转发到动态 举报
写回复
用AI写文章
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

7,762

社区成员

发帖
与我相关
我的任务
社区描述
VB 基础类
社区管理员
  • VB基础类社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧