📄 modini.bas
字号:
Attribute VB_Name = "mod_ini"
Option Explicit
'lpBuffer : buffer for system directory
'uSize : size of directory buffer
Private Declare Function GetSystemDirectory Lib "kernel32" Alias "GetSystemDirectoryA" _
(ByVal lpBuffer As String, ByVal nSize As Long) As Long
'lpAppName : section name
'lpKeyName : key name
'lpDefault : default string
'lpReturnedString : destination buffer
'nSize : size of destination buffer
'lpFileName : initialization file name
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
'lpAppName : section name
'lpKeyName : key name
'lpString : string to add
'lpFileName : initialization file
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配置文件中读取指定段名、关键字名的值
'// 调用语法: GetInIKeyValue(SectionName as string,KeyName As String,FileName As String)
'// 参数说明:
'// SectionName :段名
'// KeyName :关键字名
'// FileName :ini文件名包括路径
'// 返 回 值:
'// String :返回关键字值
'// 处理说明:
'// 调用API函数GetPrivateProfileString
'//////////////////////////////////////////////////////////////////////////////
Public Function GetInIKeyValue(ByVal SectionName As String, _
ByVal KeyName As String, _
ByVal FileName As String) As String
Dim KeyValue$
Dim strTmp As String
KeyValue$ = String$(512, " ")
GetPrivateProfileString SectionName, KeyName, "", KeyValue$, 512, FileName
strTmp = Trim(KeyValue$)
GetInIKeyValue = Left(strTmp, Len(strTmp) - 1)
End Function
'////////////////////////////////////////////////////////////////////////////////
'// 函数功能:从ini配置文件中写入指定段名、关键字名及值
'// 调用语法: SetInIKeyValue(SectionName as string,KeyName As String,KeyValue as string ,FileName As String)
'// 参数说明:
'// SectionName :段名
'// KeyName :关键字名
'// KeyValue :关键字值
'// FileName :ini文件名包括路径
'// 返 回 值:
'// 处理说明:
'// 调用API函数WritePrivateProfileString
'//////////////////////////////////////////////////////////////////////////////
Public Sub SetInIKeyValue(ByVal SectionName As String, _
ByVal KeyName As String, _
ByVal KeyValue As String, _
ByVal FileName As String)
Dim lng As Long
lng = WritePrivateProfileString(SectionName, KeyName, KeyValue, FileName)
End Sub
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -