首 页 行业热点 新车 试驾评测 养车用车 车型库

用VB实现读取/写入INI配置文件的问题.

发布网友 发布时间:4小时前

我来回答

1个回答

热心网友 时间:7分钟前

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
Private Declare Function WritePrivateProfileString Lib "kernel32" _
Alias "WritePrivateProfileStringA" (ByVal lpApplicationName As String, _
ByVal lpKeyName As Any, ByVal lpString As Any, _
ByVal lpFileName As String) As Long
Function GetFromIni(strSectionHeader As String, strVariableName As String, strFileName As String) As String
Dim strReturn As String
strReturn = String(255, Chr(0))
GetFromIni = Left$(strReturn, GetPrivateProfileString(strSectionHeader, ByVal strVariableName, "", strReturn, Len(strReturn), strFileName))
End Function
Private Sub Command1_Click()
Dim success As Long
success = WritePrivateProfileString("系统配置", "load", Text1.Text, "c:\cf.ini")
End Sub

Private Sub command2_click()
Text1.Text = GetFromIni("系统配置", "load", "c:\cf.ini")
End Sub

声明声明:本网页内容为用户发布,旨在传播知识,不代表本网认同其观点,若有侵权等问题请及时与本网联系,我们将在第一时间删除处理。E-MAIL:11247931@qq.com