📄 mdlfunctions.bas
字号:
Attribute VB_Name = "mdlFunctions"
Option Explicit
'=============================================================================
'ini文件管理api函数声明
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
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
Declare Function WritePrivateProfileSection Lib "kernel32" _
Alias "WritePrivateProfileSectionA" ( _
ByVal lpAppName As String, _
ByVal lpString As Any, _
ByVal lpFileName As String) As Long
'=============================================================================
'*****************************************************************************
'功能:ini读取函数
'参数:
'返回值:
'*****************************************************************************
Public Function ReadString(Section As String, Key As String, Size As Long, File As String) As String
Dim ReturnStr As String
Dim ReturnLng As Long
ReadString = vbNullString
ReturnStr = Space(Size)
ReturnLng = GetPrivateProfileString(Section, Key, vbNullString, ReturnStr, Size, File)
ReadString = Left(ReturnStr, ReturnLng)
End Function
'*****************************************************************************
'功能:ini写入函数
'参数:
'返回值:
'*****************************************************************************
Public Function WriteString(Section As String, Key As String, Value As String, File As String) As Boolean
WriteString = False
If Value = "0&" Then
If WritePrivateProfileString(Section, Key, 0&, File) = 0 Then
Exit Function
End If
Else
If WritePrivateProfileString(Section, Key, Value, File) = 0 Then
Exit Function
End If
End If
WriteString = True
End Function
'*****************************************************************************
'功能:ini文件 字段 写入函数
'参数:
'返回值:
'*****************************************************************************
Public Function WriteSection(Section As String, Value As String, File As String) As Boolean
WriteSection = False
If Value = "0&" Then
If WritePrivateProfileSection(Section, 0&, File) = 0 Then
Exit Function
End If
Else
If WritePrivateProfileSection(Section, Value, File) = 0 Then
Exit Function
End If
End If
WriteSection = True
End Function
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -