Option Explicit
' By音符,QQ:337855632 Time:2020-03-17 功能定制:20元起
Class File_Class
    Private WritePrivateProfileString, GetPrivateProfileString
    Public Function ReadINI(ByVal ApplicationName, ByVal KeyName, ByVal IniPath, ByVal Default)
        Dim retstr
        retstr = Space(255)
        ReadINI = left(retstr, Api.ECall(GetPrivateProfileString, False, ApplicationName, KeyName, Default, retstr, 255, IniPath))
    End Function
    Public Function WriteINI(ByVal ApplicationName, ByVal KeyName, ByVal Str, ByVal IniPath)
        Call Api.ECall(WritePrivateProfileString, False, ApplicationName, KeyName, CStr(Str), IniPath)
    End Function
    Function ReadFile(FileName)
        Dim fso, myfile
        Set fso = CreateObject("scripting.FileSystemObject")
        If fso.FileExists(FileName) Then
            Set myfile = fso.OpenTextFile(FileName, 1, False)
            If Not myfile.AtEndOfStream Then
                ReadFile = myfile.ReadAll
            End If
            myfile.Close
        End If
    End Function
    Function ReadFileEx(FilePath,Charset)
        With CreateObject("Adodb.Stream")
            .Type = 2
            .mode = 3
            .charset = Charset
            .Open
            .LoadFromFile FilePath
            ReadFileEx = .readtext
            .close
        End With
    End Function
    Private Sub Class_Initialize()
        Dim hModule
        hModule = "kernel32"
        WritePrivateProfileString = Api.ProcAddress(hModule,"WritePrivateProfileStringW")
        GetPrivateProfileString = Api.ProcAddress(hModule,"GetPrivateProfileStringW")
        Call Api.ProcAddress(-hModule)	'FreeLibrary'
    End Sub
End Class