zoukankan      html  css  js  c++  java
  • 调用Config.ini类

    private static string sPath = @Directory.GetCurrentDirectory() + "\config.ini";
    [DllImport("kernel32")]
    private static extern long WritePrivateProfileString(string section, string key, string val, string filePath);
    [DllImport("kernel32")]
    private static extern int GetPrivateProfileString(string section, string key, string def, StringBuilder retVal, int size, string filePath);

    public static void Writue(string section, string key, string value)
    {
    // section=配置节,key=键名,value=键值,path=路径
    WritePrivateProfileString(section, key, value, sPath);
    }

    public static string ReadValue(string section, string key)
    {
    // 每次从ini中读取多少字节
    System.Text.StringBuilder temp = new System.Text.StringBuilder(255);
    // section=配置节,key=键名,temp=上面,path=路径
    GetPrivateProfileString(section, key, "", temp, 255, sPath);
    return temp.ToString(); //注意类型的转换
    }

    比如

    int Forecast = Convert.ToInt32(iniSet.ReadValue("1", "1"));

  • 相关阅读:
    Mybatis中#{}与${}的区别:
    JDBC
    JavaScript与jQuery的区别
    JavaScript 高级
    AdminLTE
    servlet过滤器与监听器
    数据库连接池
    大对象数据LOB的应用
    Serializable
    泛型
  • 原文地址:https://www.cnblogs.com/panjuan/p/4757643.html
Copyright © 2011-2022 走看看