GetPrivateProfileString 读取INI文件的API函数 感觉很简单

Naola2001 2002-09-13 03:01:05
GetPrivateProfileString 读取INI文件的API函数
以下是其中一个参数的说明:
String,欲获取的项名或条目名。这个字串不区分大小写。如设为vbNullString,就在lpReturnedString缓冲区内装载指定小节所有项的列表

在我的程序里lpReturnedString 现在里面有一大堆东西了,但是怎么一条条取出来呢?


Private Sub Form_Load()
Dim lpAppName As String, lpFileName As String, lpKeyName As String, lpString As String
Dim Temp As String * 50
Dim U As Long
lpAppName = vbNullString
lpKeyName = vbNullString
lpString = ""
lpFileName = "D:\BB.ini"
U = GetPrivateProfileString(lpAppName, lpKeyName, lpString, Temp, Len(Temp), lpFileName)
If U = 0 Then
Beep
End If
LS.AddItem Temp
End Sub
...全文
137 2 打赏 收藏 转发到动态 举报
写回复
用AI写文章
2 条回复
切换为时间正序
请发表友善的回复…
发表回复
Naola2001 2002-09-13
  • 打赏
  • 举报
回复
还是没说明白
nik_Amis 2002-09-13
  • 打赏
  • 举报
回复
Public Function PutToINI(ByVal sApp As String, ByVal sKey As String, ByVal sValue As String) As Boolean
Dim lReturn As Long
Dim sFilename As String

sFilename = App.Path & "\" & gcsINIFileName
lReturn = WritePrivateProfileString(sApp, sKey, sValue, sFilename)
PutToINI = (lReturn = 1)
End Function

Public Function GetInINI(ByVal sApp As String, ByVal sKey As String, ByRef sValue As String) As Boolean
Dim lReturn As Long
Dim sBuffer As String
Dim sFilename As String

On Error Resume Next
sFilename = App.Path & "\" & gcsINIFileName
sBuffer = String(1024, 0)
lReturn = GetPrivateProfileString(sApp, sKey, "", sBuffer, 1024, sFilename)
sValue = Left(sBuffer, lReturn)
GetInINI = (Err.Number = 0)
End Function

1,486

社区成员

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

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