This is VB code, create a new ActiveX DLL, and then change the project name and class name, and then enter the following content in the class.
'//////////////////////////////
' Chinese name: INI file operation class
' English name: Blood_ini Class
' Author: Blood
' Production time: 2002.2.8
' Version: 1.0
' All rights reserved Blood 2002-2003
'//////////////////////////////
' Declare the variable
Private strappname as String ' INI subsection name
Private strkeyname as String ' INI project name
Item value for Private strvaluestr as String ' ini
Private strFileName as String ' INI file name
' Declare the API for Operation INI file
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 NS Ize as Long, 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 String, ByVal lpFileName as String) as Long
'////////////////////
' Start defining functions
'////////////////////
' Define functions to write INI file
Public Function Writeini () as Long
' Write value to INI file via API
Writeini = WritePrivateProfileString (Strappname, Strkeyname, Strvaluestr, strFileName)
End Function
' Defines a function to read the INI file
Public Function Getini () as String
Const string_size = 255 ' Specify string length
Dim lnglength as Long ' defines the length that the API function returns
Dim Strdefault as String * string_size ' defines the default value that is returned when no specified item is found
Dim Strreturn As String * string_size ' defines a string buffer
' Get the contents of the INI file via API function
Lnglength = GetPrivateProfileString (Strappname, Strkeyname, Strdefault, Strreturn, String_size, StrFileName)
' Determines the returned value by judging the length returned by the API function
If (lnglength = 0) Then
Getini = Strvaluestr
Else
Getini = Mid (Strreturn, 1, lnglength)
End If
End Function
'////////////////////
' Define function end
'////////////////////
'////////////////////
' Start defining properties
'////////////////////
' Get the name of the INI file
Public Property Let FileName (ByVal strfile as String)
strFileName = strfile
End Property
' Get Project value
Public Property Let Valuestr (ByVal strvalue as String)
Strvaluestr = strvalue
End Property
' Get project Name
Public Property Let KeyName (ByVal strkey as String)
Strkeyname = Strkey
End Property
' Get the section name
Public Property Let AppName (ByVal Strapp as String)
Strappname = Strapp
End Property
'////////////////////
' End definition attribute
'////////////////////