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"));

  • 相关阅读:
    起泡排序引申出的问题
    关于NPC和NP-Hard问题
    我的书单(更新中)
    OpenCV2学习笔记03:Qt中配置OpenCV环境
    Ubuntu 14.04为浏览器添加Flash插件
    CSS3基础
    HTML5进阶
    拖拽上传及读取文件实现
    生产者消费者模型
    进程
  • 原文地址:https://www.cnblogs.com/panjuan/p/4757643.html
Copyright © 2011-2022 走看看