你用什么开发的呀。我这是 vb 的
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
Public Function read_ini(sINIfile As String, sSection As String, sKey As String, sDefault As String) As String
On Error GoTo err_msg
Dim sTemp As String * 256
Dim nLength As Integer
sTemp = Space$(256)
nLength = GetPrivateProfileString(sSection, sKey, sDefault, sTemp, _
256, sINIfile)
read_ini = Left$(sTemp, nLength)
Exit Function
err_msg:
MsgBox "Read system ini.file is wrong!", vbInformation + vbOKOnly, "system error!"
End Function
Public Sub write_ini(sINIfile As String, sSection As String, sKey As String, sValue As String)
On Error GoTo err_msg
Dim n As Integer
Dim sTemp As String
sTemp = sValue
For n = 1 To Len(sValue)
If Mid$(sValue, n, 1) = vbCr Or Mid$(sValue, n, 1) = vbLf Then _
Mid$(sValue, n) = ""
Next n
n = WritePrivateProfileString(sSection, sKey, sTemp, sINIfile)
Exit Sub
err_msg:
MsgBox "write system ini.file is wrong!", vbInformation + vbOKOnly, "system error!"
End Sub