在一个HTML文件中设置一个参数,参数名(name)为“string”,值(value)
发布网友
发布时间:2022-04-20 13:00
我来回答
共1个回答
热心网友
时间:2022-04-20 14:29
======================================
'Ini操作声明
'==================================================
Dim Ret As Long
Dim Start As Long
Public FileName As String
Public MaxthonPath As String
Public TimeID As Integer
Const BufSize = 10240
Dim buf As String * BufSize
Private Declare Function GetPrivateProfileInt Lib "kernel32" Alias "GetPrivateProfileIntA" (ByVal lpApplicationName As String, ByVal lpKeyName As String, ByVal nDefault 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
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 WritePrivateProfileSection Lib "kernel32" Alias "WritePrivateProfileSectionA" (ByVal lpAppName As String, ByVal lpString As String, 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
'============================
'操作INI文件函数
'============================
Public Function SetValue(ByVal clsName As String, ByVal key As String, ByVal V As String) As Boolean
Ret = WritePrivateProfileString(clsName, key, V, FileName)
End Function
Public Function GetValue(ByVal clsName As String, ByVal key As String) As String
Ret = GetPrivateProfileString(clsName, key, "", buf, BufSize, FileName)
Start = 1
GetValue = RetStr()
End Function
Private Function RetStr() As String
Dim i As Long
i = InStr(Start, buf, Chr(0))
If i > Start Then
RetStr = Mid(buf, Start, i - Start)
End If
Start = i + 1
End Function
'代码示例
设置值
SetValue(根, 参数名, 参数值)
获取值
GetValue(根, 参数名)
在程序初始化部分还要赋值FileName
FileName = app.path & "\" & app.exeName & ".ini"
如果你的ini配置文件与exe程序同名的话就用上面 其它你自己根据情况改