日期:2014-05-17 浏览次数:20941 次
/// <summary> ini文件操作类,主要有创建、读、写
///
/// </summary>
public class IniFile
{
private string IniFileName;
[DllImport("kernel32")]
private static extern int GetPrivateProfileInt(string lpAppName, string lpKeyName,
int nDefault, string lpFileName);
[DllImport("kernel32")]
private static extern int GetPrivateProfileString(string lpAppName, string lpKeyName,
string lpDefault, StringBuilder lpReturnedString, int nSize, string lpFileName);
[DllImport("kernel32")]
private static extern bool WritePrivateProfileString(string lpAppName,
string lpKeyName, string lpString, string lpFileName);
//注意这里就使用了GetPrivateProfileString方法,来自于外部DLL“kernel32”
//要什么参数及返回什么结果,这个就看开发文档SDK
/// <summary>
/// 读ini的指定节点、key的值(string)
/// </summary>
/// <param name="Section"></param>
/// <param name="Key"></param>
/// <param name="Default"></param>
/// <returns></returns>
public string ReadIni(string Section, string Key, string Default)
{
StringBuilder temp = new StringBuilder(1024);
int rec =&