怎么往 INI 文件了加内容(非常紧急)
我现在准备在 INI 文件里间数据库,不知道怎么往里边加啊,希望高手们帮忙啊
现在这里是我自己写的
Private JLH As Integer '变量JLH用来保存记录号
' 声明用户自定义类型,即记录类型
Private Type XTPZDATATYPE '自定义类型的名称为XTPZDATATYPE
XTPZID As String * 4 '计算机ID号
XTPZLocation As String * 20 '安装的地点
XTPZIP As String * 20 '网络IP地址
XTPZTime As String * 10 '安装的时间
End Type
Dim XTPZTYPE As XTPZDATATYPE '讲变量XTPZTYPE定义为自定义类型
Dim i As Integer
'添加记录
Private Sub CommandTJ_Click()
下边就不知道怎么写了阿,请高手们帮帮我啊,最好把源码写上啊,我先谢谢了啊,我再线上等你们啊!!!!
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 Declare Function GetPrivateProfileSectionNames Lib "kernel32.dll" Alias "GetPrivateProfileSectionNamesA" (ByVal lpszReturnBuffer As String, ByVal nSize As Long, ByVal lpFileName As String) As Long
Private Declare Function GetPrivateProfileSection Lib "kernel32" Alias "GetPrivateProfileSectionA" (ByVal lpAppName As String, ByVal lpReturnedString As String, ByVal nSize As Long, ByVal lpFileName As String) As Long
Public Function SetINIItem(ByVal sApp As String, ByVal sKey As String, ByVal sValue As String) As Boolean
Dim lReturn As Long, sFileName As String
sFileName = App.Path & "\" & INI_FILENAME
lReturn = WritePrivateProfileString(sApp, sKey, sValue, sFileName)
SetINIItem = (lReturn = 1)
End Function
Public Function GetINIItem(ByVal sApp As String, ByVal sKey As String) As String
Dim lReturn As Long, sBuffer As String, sFileName As String, c As Long, sValue As String
On Error Resume Next
sFileName = App.Path & "\" & INI_FILENAME
sBuffer = String(1024, 0)
lReturn = GetPrivateProfileString(sApp, sKey, "", sBuffer, 1024, sFileName)
c = InStr(1, sBuffer, Chr(0)) - 1
If c > 0 Then sValue = Left$(sBuffer, c) Else sValue = ""
GetINIItem = sValue
End Function
Private Sub Command1_Click() '写文件
XTPZTYPE.XTPZID = "0001"
XTPZTYPE.XTPZlocation = "C:\WINDOWS\SYSTEM32"
WritePrivateProfileSection "SysInfo", "", App.Path + "\test.ini"
WritePrivateProfileSection "Computer Name", "", App.Path + "\test.ini"
WritePrivateProfileString "SysInfo", "代号", CStr(XTPZTYPE.XTPZID), App.Path + "\test.ini"
WritePrivateProfileString "SysInfo", "路径", CStr(XTPZTYPE.XTPZlocation), App.Path + "\test.ini"
end sub