using System;using System.Drawing;using System.Collections;using System.ComponentModel;using System.Windows.Forms;using System.IO;using System.Runtime.InteropServices;using System.Text;//申明INI文件的写操作函数WritePrivateProfileString()[DllImport("kernel32")] private static extern long WritePrivateProfileString(string section, string key, string val, string filePath);//申明INI文件的读操作函数GetPrivateProfileString()[DllImport("kernel32")] private static extern int GetPrivateProfileString(string section, string key, string def, StringBuilder retVal, int size, string filePath);private void readIni_Click(object sender, EventArgs e)...{ //string str_age = "99"; //long write_val = WritePrivateProfileString("name", "age", str_age, "test.ini"); //MessageBox.Show(str_age); StringBuilder strb = new StringBuilder(); int get_val = GetPrivateProfileString("name", "sex", "", strb, 255, "test.ini"); MessageBox.Show(strb.ToString());}