 using System;
using System;
 using System.Text;
using System.Text;
 using System.Runtime.InteropServices;
using System.Runtime.InteropServices;
 namespace Common.Text
namespace Common.Text


 {
{
 public class INIFile
 public class INIFile

 
  {
{
 public string path;
  public string path;

 public INIFile(string INIPath)
  public INIFile(string INIPath)

 
   {
{
 path = INIPath;
   path = INIPath;
 }
  }

 [DllImport("kernel32")]
  [DllImport("kernel32")]
 private static extern long WritePrivateProfileString(string section,
  private static extern long WritePrivateProfileString(string section,
 string key,string val,string filePath);
   string key,string val,string filePath);

 [DllImport("kernel32")]
  [DllImport("kernel32")]
 private static extern int GetPrivateProfileString(string section,
  private static extern int GetPrivateProfileString(string section,
 string key,string def, StringBuilder retVal,int size,string filePath);
   string key,string def, StringBuilder retVal,int size,string filePath);

 public void IniWriteValue(string Section,string Key,string Value)
  public void IniWriteValue(string Section,string Key,string Value)

 
   {
{
 WritePrivateProfileString(Section,Key,Value,this.path);
   WritePrivateProfileString(Section,Key,Value,this.path);
 }
  }


 public string IniReadValue(string Section,string Key)
  public string IniReadValue(string Section,string Key)

 
   {
{
 StringBuilder temp = new StringBuilder(255);
   StringBuilder temp = new StringBuilder(255);

 int i = GetPrivateProfileString(Section,Key,"",temp, 255, this.path);
   int i = GetPrivateProfileString(Section,Key,"",temp, 255, this.path);

 return temp.ToString();
   return temp.ToString();

 }
  }

 }
 }

 }
}

 
	
 posted on 
2007-11-29 15:05 
wskfire 
阅读(
199) 
评论() 
 
收藏 
举报