I do not know how to use the previous days I wrote the operation of the INI file com? I'll post the code.

Source: Internet
Author: User
Tags define function ini
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
'////////////////////



Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.