Option Explicit On
Module INI
'INICont.bas Ver 1.0+a INI '====================================================================
'GetIntFromINI( sectionName , keyName , defaultValue, iniPath )
'
' sectionName:节点名
'KeyName: configuration item name
' defaultValue: defaults
'IniPath: INI path of the profile
'
'====================================================================
// get a statement from the INI configuration file type for the system function value Int configuration items of
Private Declare Function GetPrivateProfileInt Lib "kernel32" Alias "GetPrivateProfileIntA" (ByVal lpAppName As String, ByVal lpKeyName As String, ByVal nDefault As Integer, ByVal lpFileName As String) As Integer
// get the type of statement from the INI configuration files for the system function value of the configuration item string of
Private Declare Function GetPrivateProfileString Lib "kernel32" Alias "GetPrivateProfileStringA" (ByVal lpAppName As String, ByVal lpKeyName As String, ByVal lpDefault As String, ByVal lpReturnedString As String, ByVal nSize As Integer, ByVal lpFileName As String) As Integer
// statement to the INI configuration file written to a value of type configuration item string of system functions
Private Declare Function WritePrivateProfileString Lib "kernel32" Alias "WritePrivateProfileStringA" (ByVal lpAppName As String, ByVal lpKeyName As String, ByVal lpString As String, ByVal lpFileName As String) As Integer
// Get the INI configuration file from a value of type configuration item of the Int
Public Function GetIntFromINI(ByVal sectionName As String, ByVal keyName As String, ByVal defaultValue As Integer, ByVal iniPath As String) As Integer
GetIntFromINI = GetPrivateProfileInt(sectionName, keyName, defaultValue, iniPath)
End Function
// Get the type from the INI value string profile configuration items
Public Function GetStrFromINI (ByVal sectionName of As String, ByVal the keyName of As String, ByVal defaultValue of As String, ByVal iniPath of As String) of As String
Dim of As String Buffer
Dim rc As Integer
buffer = Space(256)
rc = GetPrivateProfileString(sectionName, keyName, defaultValue, buffer, buffer.Length, iniPath)
GetStrFromINI = Left(buffer, InStr(buffer, vbNullChar) - 1)
End Function
Value type of configuration item string // write to the INI configuration file
Public Function WriteStrINI(ByVal sectionName As String, ByVal keyName As String, ByVal setValue As String, ByVal iniPath As String) As Integer
Dim rc As Integer
rc = WritePrivateProfileString(sectionName, keyName, setValue, iniPath)
If rc Then
rc = 1
End If
WriteStrINI = rc
End Function
End Module
Reproduced in: https: //www.cnblogs.com/kevinGao/archive/2011/09/27/2224218.html