C# 调用API函数创建INI文件
1.首先导入命名空间:using System.Runtime.InteropServices;
2.声明API函数:
1 [DllImport("kernel32")] 2 private static extern long WritePrivateProfileString(string section, string key, string val, string filePath); 3 [DllImport("kernel32")] 4 private static extern int GetPrivateProfileString(string section, string key, string def, StringBuilder retVal, int size, string filePath);
3.创建ini文件:
WritePrivateProfileStirng(section,key,value,filepath);
4.读取ini文件:
StringBuilder temp=new StringBuilder(); GetPrivateProfileString(section,key,default,temp,255,filepath);

浙公网安备 33010602011771号