无法正常读取,请教。
test.ini
[main]
asdf=123
qwer=234
VB代码
Option Explicit
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
Private Sub Command1_Click()
Dim strTemp As String
Dim i As Long
strTemp = Space(64)
i = GetPrivateProfileString("[main]", "asdf", "error", strTemp, Len(strTemp), "D:\test.ini")
Me.Print Left(strTemp, i)
End Sub
test.ini
[main]
asdf=123
qwer=234
VB代码
Option Explicit
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
Private Sub Command1_Click()
Dim strTemp As String
Dim i As Long
strTemp = Space(64)
i = GetPrivateProfileString("[main]", "asdf", "error", strTemp, Len(strTemp), "D:\test.ini")
Me.Print Left(strTemp, i)
End Sub