1using System;
 2using System.IO ;
 3using System.Text ;
 4using System.Runtime .InteropServices;
 5
 6namespace namespace
 7{
 8    /// <summary>
 9    /// PreeClsIni 的摘要说明。
10    /// </summary>

11    public class PreeClsIni
12    {        
13        public PreeClsIni()
14        {
15            //
16            // TODO: 在此处添加构造函数逻辑
17            //
18        }
        
19        
20
21    }

22    public class INIFile
23  {
24    public string path;
25    public INIFile(string INIPath)
26    {
27      path = INIPath;
28    }

29
30    [DllImport("kernel32")]
31    private static extern long WritePrivateProfileString(
32      string section,string key,string val,string filePath);
33
34    [DllImport("kernel32")]
35    private static extern int GetPrivateProfileString(string section,
36      string key,string def, StringBuilder retVal,int size,string filePath);
37
38    public void IniWriteValue(string Section,string Key,string Value)
39    {
40      WritePrivateProfileString(Section,Key,Value,this.path);
41    }

42
43    public string IniReadValue(string Section,string Key)
44    {
45      StringBuilder temp = new StringBuilder(255);
46
47      int i = GetPrivateProfileString(Section,Key,"",temp, 255this.path);
48
49      return temp.ToString();
50    }

51
52  }

53
54}

55