读写入INI文件

读写入INI文件

引用写入dll

 [DllImport("kernel32")]
private static extern long WritePrivateProfileString(string section, string key, string val, string    filePath);

写入ini

public void IniWriteValue(string Section, string Key, string Value)
  {
   string inipath = ".CONFIG.INI";
   WritePrivateProfileString(Section, Key, Value, inipath);
  }

调用

public void IniWriteValues() {
   IniWriteValue("CONFIG", "Comport", ComPort);
  }

引用读取dll

  [DllImport("kernel32.dll")]
  private static extern int GetPrivateProfileString(string section, string key, string def,  StringBuilder retVal, int size, string INIPath);

调用

 StringBuilder temp = new StringBuilder(500);
   GetPrivateProfileString("CONFIG", "Player", "", temp, 500, ".\CONFIG.INI");
   Player = temp.ToString();
发布了19 篇原创文章 · 获赞 0 · 访问量 445

猜你喜欢

转载自blog.csdn.net/qq_35624605/article/details/103926598
今日推荐