r/> /// 获取所有的值集合
/// </summary>
public ICollection Values
{
get {return Dictionary.Values;}
}
/// <summary>
/// 添加一个可能不存在的配置项(创建一个配置项)
/// </summary>
/// <param name="vName">配置项名</param>
/// <param name="vValue">配置项值</param>
/// <returns>创建的配置项INIItem对象</returns>
public INIItem Add(string vName,string vValue)
{
if(Dictionary.Contains(vName))
return (INIItem)Dictionary[vName];
else
{
INIItem o=new INIItem(this,vName,vValue);
this.Add(o);
return o;
}
}
/// <summary>
/// 获取指定索引的配置项
/// </summary>
public INIItem this[string vName]
{
get {
if(Dictionary.Contains(vName))
return (INIItem)Dictionary[vName];
else
return this.Add(vName,"");
}
}
}
/// <summary>
/// INI文件操作类
/// </summary>
public class INIFile
{
#region 导入DLL函数
[DllImport("kernel32.dll")] public extern static int GetPrivateProfileIntA(string segName,string keyName,int iDefault,string fileName);
[DllImport("kernel32.dll")] public extern static int GetPrivateProfileStringA(string segName,string keyName,string sDefault,StringBuilder retValue,int nSize,string fileName);
[DllImport("kernel32.dll")] public extern static int GetPrivateProfileSectionA(string segName,byte [] sData,int nSize,string fileName);
[DllImport("kernel32.dll")] public extern static int WritePrivateProfileSectionA(string segName,byte [] sData,string fileName);
[DllImport("kernel32.dll")] public extern static int WritePrivateProfileStringA(string segName,string keyName,string sValue,string fileName);
[DllImport("kernel32.dll")] public extern static int GetPrivateProfileSectionNamesA(byte [] vData,int iLen,string fileName);
#endregion