zoukankan      html  css  js  c++  java
  • 读取INI配置文件

    config.ini文件

    [System]
    Ttype=False
    TMode=0
    TErrMode=1
    SaveTemp=0
    TControl=0
    Password=sa
    LoadMax=1000

    LoadMin=-1000

    Public Declare Function GetPrivateProfileString Lib "kernel32" Alias "GetPrivateProfileStringA" (ByVal lpApplicationName As String, ByVal lpKeyName As Any, ByVal lpDefault As String, ByVal lpReturnedString As String, ByVal nSize As Long, ByVal lpFileName As String) As Long
    Public Declare Function WritePrivateProfileString Lib "kernel32" Alias "WritePrivateProfileStringA" (ByVal lpApplicationName As String, ByVal lpKeyName As Any, ByVal lpString As Any, ByVal lpFileName As String) As Long
    
    Public Function GetIniStr(ByVal AppName As String, ByVal In_Key As String, iniFileName As String) As String
        On Error GoTo GetIniStrErr
        If VBA.Trim(In_Key) = "" Then
            GoTo GetIniStrErr
        End If
        Dim GetStr As String
        GetStr = VBA.String(128, 0)
        GetPrivateProfileString AppName, In_Key, "", GetStr, 256, iniFileName
        GetStr = VBA.Replace(GetStr, VBA.Chr(0), "")
        If GetStr = "" Then
            GoTo GetIniStrErr
        Else
            GetIniStr = GetStr
            GetStr = ""
        End If
        Exit Function
    GetIniStrErr:
        Err.Clear
        GetIniStr = ""
        GetStr = ""
    End Function
    
    
    '
    Public Function WriteIniStr(ByVal AppName As String, ByVal In_Key As String, ByVal In_Data As String, iniFileName As String) As Boolean
        On Error GoTo WriteIniStrErr
        WriteIniStr = True
        If VBA.Trim(In_Data) = "" Or VBA.Trim(In_Key) = "" Or VBA.Trim(AppName) = "" Then
            GoTo WriteIniStrErr
        Else
            WritePrivateProfileString AppName, In_Key, In_Data, iniFileName
        End If
        Exit Function
    WriteIniStrErr:
        Err.Clear
        WriteIniStr = False
    End Function
    Dim loadMax As Double
    dim LoadMin as double 
     IniFilePath = App.Path & "SystemIni.ini"
       
     loadMax = GetIniStr("System", "LoadMax", IniFilePath)    ''1000
    LoadMin = GetIniStr("System", "LoadMin", IniFilePath)      ''-1000
  • 相关阅读:
    CF225E Unsolvable
    CF1100E Andrew and Taxi
    oracle数据库导入导出方法
    ORACLE无法删除当前连接用户
     为什么上传文件的表单里要加个属性enctype----摘录
    ecplise 使用快捷键
    spring工作机制及为什么要用?
    阐述struts2的执行流程。
    Hibernate工作原理及为什么要用?
    Mybatis 如何自动生成bean dao xml 配置文件 generatorconfig.xml (main()方法自动生成更快捷)
  • 原文地址:https://www.cnblogs.com/rosesmall/p/11691620.html
Copyright © 2011-2022 走看看