using System.IO;
using System.Runtime.InteropServices;
using System.Text;
//要调用WINDOWS API函数首先得引用System.Runtime.InteropServices
private System.ComponentModel.Container components = null;
[DllImport("kernel32")]
public static extern long WritePrivateProfileString(string section,string key,string val,string filePath);
[DllImport("kernel32")]
public static extern int GetPrivateProfileString(string section,string key,string def,StringBuilder retVal,int size,string filePath);
//声明API
WritePrivateProfileString("Database Setting","Server",this.data_server,filename);
//读取INI文件,("Database Setting"为节点,"Server"为节点的一个子项名,this.data_server接受"Server"子项的值,filename是INI文件的路径);
StringBuilder temp = new StringBuilder(255);
GetPrivateProfileString("Database Setting","Server","",temp,255,filename);
//同上,TEMP读取的是"server"的值,