Public 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 你是怎么用这个Api的??我想取值时以一标志分隔注释就ok了吧 如: Public Function GetPrivateIni(ByVal ApName As String, ByVal KeyName As String, ByVal strDefault As String, _ ByVal strFileName As String) As String Dim lnLength As Long Dim strBuff As String strBuff = String(256, 0) lnLength = GetPrivateProfileString(ApName, KeyName, strDefault, strBuff, _ Len(strBuff), strFileName) strBuff = Left(strBuff, InStr(strBuff, ";") - 1) If strBuff = Chr(0) Then GetPrivateIni = strDefault Else GetPrivateIni = strBuff End If End Function
[option]
key1=value1 ;(这里我想加入备注,用什么字符呢?我试着用";"分号,却不行)
key2=value2
......
......
[option]
key1=value1 ;备注1
key2=value2 ;备注2我在读列表key1值的时候,需要的值是:
value1
但是结果却是:
value1 ;备注1大家能告诉我是为什么吗?
你是怎么用这个Api的??我想取值时以一标志分隔注释就ok了吧
如:
Public Function GetPrivateIni(ByVal ApName As String, ByVal KeyName As String, ByVal strDefault As String, _
ByVal strFileName As String) As String
Dim lnLength As Long
Dim strBuff As String strBuff = String(256, 0) lnLength = GetPrivateProfileString(ApName, KeyName, strDefault, strBuff, _
Len(strBuff), strFileName) strBuff = Left(strBuff, InStr(strBuff, ";") - 1)
If strBuff = Chr(0) Then
GetPrivateIni = strDefault
Else
GetPrivateIni = strBuff
End If
End Function