namespace WindowsApplication1
{
public partial class Form1 : Form
{
[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文件写操作
public void IniWriteValue(string Section, string Key, string Value, string filepath)
{
WritePrivateProfileString(Section, Key, Value, filepath);
&
C#调用API读写INI文件
最新推荐文章于 2021-03-16 08:34:31 发布
该博客介绍了如何在C#中通过调用kernel32.dll API来实现对INI文件的读写操作。提供了两个方法,一个是IniWriteValue用于写入数据,另一个是IniReadValue用于读取数据。示例代码展示了在按钮点击事件中读取和写入INI文件的具体实现。

最低0.47元/天 解锁文章
671

被折叠的 条评论
为什么被折叠?



