调用Config.ini类
2015-08-25 15:40
281 查看
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"));
[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"));
相关文章推荐
- 404 Not Found 由来
- Java-数组
- Implicit super constructor BaseService() is undefined. Must explicitly invoke another constructor
- 计算机网络组网与配置技术—— 读书笔记3、传输介质和组网连接方法
- windows内核编程基础篇之字符串的处理
- MFC程序的启动过程与相关函数执行顺序
- JavaScript面向对象编程学习笔记
- Sizeof与Strlen的区别与联系
- 堆区和栈区的区别
- 今天写完Assembly的小tips
- 在eclipse中添加新软件 从JAVASE 到 JAVAEE
- Java泛型:类型檫除、模板和泛型传递
- poj 1562 DFS+枚举
- JVM(三):类加载机制(类加载过程和类加载器)
- 保安装富二代诈骗30名女子50万 主攻大龄单身剩女
- QT构造函数中*parent
- 什么是接口 编程中关于接口的理解
- 线程池
- vagrant up default: Warning: Connection timeout. Retrying
- winform用AForge拍照功能