⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 module2.bas

📁 这个源代码主要模仿了一个类似 深度操作系统安装程序中的一个软件自动安装管理器AutoIt v3
💻 BAS
字号:
Attribute VB_Name = "Module2"

'**************************************
'Windows API/Global Declarations for :Ge
'     tINISectionList
'**************************************


Declare Function MDGetPrivateProfileSection Lib "kernel32" Alias "GetPrivateProfileSectionA" (ByVal lpAppName As String, ByVal lpReturnedString As String, ByVal nSize As Long, ByVal lpFileName As String) As Long
    Global Const MDG_MAX_INI_READ = 32767

'**************************************
' Name: GetINISectionList
' Description:Returns a Delimited list c
'     ontaining the elements from a specified
'     InI file section
' By: Killcrazy
'
'
' Inputs:INIFile Section Name
'iniFile Path
'strDelimiter
'
' Returns:Delimited String of ini file s
'     ection elements
'
'Assumes:You should be able to understan
'     d and maintain the code that i have post
'     ed as i have spent a lot of time comment
'     ing it so that it is easier to read
'
'Side Effects:none
'This code is copyrighted and has limite
'     d warranties.
'Please see http://www.Planet-Source-Cod
'     e.com/xq/ASP/txtCodeId.2479/lngWId.1/qx/
'     vb/scripts/ShowCode.htm
'for details.
'**************************************



Public Function GetINISectionList(ByVal strSection As String, ByVal strINIFileName As String, ByVal strDelimiter As String) As String
    Dim strReturn As String
    Dim lngPointer As Long
    Dim lngEqualsPosition As Long
    Dim lngSeperatorPosition As Long
    
    ' If 'strSection' or 'strINIFileName' ar
    '     e empty.


    If Len(strSection) = 0 Or Len(strINIFileName) = 0 Then
        ' Return an empty string.
        GetINISectionList = ""
        Exit Function
    End If
    ' Set error handler in case section list
    '     cannot be obtained.
    On Error GoTo Error_Handler
    
    ' Make the return string of fixed length
    '     - must be large
    ' in case INI file section has a lot of
    '     information.
    strReturn = String(MDG_MAX_INI_READ, " ")
    
    ' Get the section information from the I
    '     NI file
    lngPointer = MDGetPrivateProfileSection(strSection, strReturn, MDG_MAX_INI_READ, strINIFileName)
    
    ' If we found the section information


    If lngPointer > 0 Then
        ' First trim off any excess characters
        strReturn = Left$(strReturn, lngPointer)
        ' Find the first occurrence of an '=' in
        '     the section list.
        lngEqualsPosition = InStr(1, strReturn, "=")
        ' While '=' signs can be found


        While lngEqualsPosition <> 0
            ' Find the next occurrence of a list ent
            '     ry seperator
            ' (chr$(0)) after the current equals sig
            '     n.
            lngSeperatorPosition = InStr(lngEqualsPosition, strReturn, Chr$(0))
            
            ' If there are no characters following t
            '     he seperator
            ' (i.e. the seperator is at the ned of t
            '     he string.)


            If lngSeperatorPosition = Len(strReturn) Then
                
                ' Remove the data from the '=' to the sp
                '     ace
                strReturn = Left$(strReturn, lngEqualsPosition - 1)
            Else
                
                ' Remove the data from the '=' to the sp
                '     ace and
                ' replace with a delimiter
                strReturn = Left$(strReturn, lngEqualsPosition - 1) & strDelimiter & Right$(strReturn, Len(strReturn) - lngSeperatorPosition)
            End If
            
            ' Find the next occurence of an '=' char
            '     acter
            lngEqualsPosition = InStr(1, strReturn, "=")
            
        Wend
    End If
    
    ' Return 'strSection' entries delimited
    '     by 'strDelimiter'.
    GetINISectionList = strReturn
    
    ' Exit Early to avoid error handler.
    Exit Function
    ' Could not extract section information.
    '
Error_Handler:
    ' Raise an error.
    Err.Raise Err.Number, "GetINISectionList", Err.Description
    
    ' Reset normal error checking.
    On Error GoTo 0
    ' Resume via fail exit point.
    Resume Exit_GetINISectionList
    ' Error handler exit point.
Exit_GetINISectionList:
    ' Could not get 'strSection' entries - r
    '     eturn an empty string.
    GetINISectionList = ""
End Function

        

⌨️ 快捷键说明

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