using System;
using System.Collections.Generic;
using System.Linq;
using System.Runtime.InteropServices;
using System.Text;
namespace Lskj.SmsSending2
{
public static class IniUtil
{
///
/// ini文件目录
///
static string Path = System.IO.Directory.GetCurrentDirectory() + "\\" + "Setting.ini";
///
/// ini文件获取数据
///
///
///
///
///
///
///
///
[DllImport("kernel32")]
private static extern int GetPrivateProfileString(string section, string key, string defVal, StringBuilder retVal, int size, string filePath);
///
/// ini文件写入数据
///
///
///
///
///
///
[DllImport("kernel32")]
private static extern long WritePrivateProfileString(string section, string key, string val, string filePath);
///
/// 写INI文件
///
/// 段落
/// 键
/// 值
public static void IniWriteValue(string section, string key, string iValue)
{
WritePrivateProfileString(section, key, iValue, Path);
}
///
/// 读取INI文件
///
/// 段落
/// 键
/// 返回的键值
public static string IniReadValue(string section, string key)
{
StringBuilder temp = new StringBuilder(255);
int i = GetPrivateProfileString(section, key, "", temp, 255, Path);
return temp.ToString();
}
}
}