基于C#winform设计。

首先创建一个类,我命名为IniFiles。并引入命名空间using System.Runtime.InteropServices;

接着,声明API函数

      [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 filePath);

写入INI函数方法

   /// <summary> 
        /// 写入INI文件 
        /// </summary> 
        /// <param name="Section">项目名称(如 [TypeName] )</param> 
        /// <param name="Key"></param> 
        /// <param name="Value"></param> 
        public void IniWriteValue(string Section, string Key, string Value)
        {
            WritePrivateProfileString(Section, Key, Value, this.inipath);
        }
View Code

相关文章:

  • 2022-03-04
  • 2021-07-30
  • 2021-09-13
  • 2021-12-14
  • 2021-08-28
猜你喜欢
  • 2022-12-23
  • 2022-12-23
  • 2021-09-25
  • 2021-06-09
  • 2021-12-30
相关资源
相似解决方案