首页 > 其他 > 详细

调用Config.ini类

时间:2015-08-25 18:19:29      阅读:264      评论:0      收藏:0      [点我收藏+]

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

调用Config.ini类

原文:http://www.cnblogs.com/panjuan/p/4757643.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!