using System; using System.Collections.Generic; using System.Text; using System.Runtime.InteropServices; namespace Pub_Class { public class ClsIni { [DllImport("kernel32")] private static extern long WritePrivateProfileString(string section, string Key, string Val, string filePath); [DllImport("kernel32")] private static extern int GetPrivateProfileString(string section, string key, string def, StringBuilder retVal, int size, string fielPath); public static bool WriteIni(string section,string key, string keyvalue,string FileName) { WritePrivateProfileString(section, key, keyvalue, FileName); return true; } public static String ReadIni(string section, string key, string FileName) { StringBuilder def = new StringBuilder(255); int i; i = GetPrivateProfileString(section, key, "没有找到!", def, 255, FileName); return def.ToString(); } } }