inimodule.bas

来自「主要功能如题」· BAS 代码 · 共 34 行

BAS
34
字号
Attribute VB_Name = "IniModule"
Public 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
Public 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 ReadIni(ByVal AppName As String, ByVal KeyName As String, ByVal FileName As String) As String

    Dim ret As Long
    Dim buff As String
    buff = Space(255)
    ret = GetPrivateProfileString(AppName, KeyName, "", buff, 256, FileName)
    ReadIni = Trim(buff)

End Function

'写INI文件
Public Function WriteIni(ByVal AppName As String, ByVal KeyName As String, ByVal strValue As String, ByVal FileName As String) As Long

    Dim ret As Long
    Dim buff As String

    buff = strValue
    ret = WritePrivateProfileString(AppName, KeyName, buff, FileName)
    WriteIni = ret

End Function

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?