Ini文件说明:
[节名] '[]中的节名对应此API的第一参数
Name=内容 'Nmae对应此API的第二参数
---------------------------------------------
API的第三参数是没有取到匹配内容时返回的字符串;
API的第四参数是要返回的字符串;
API的第五参数是字符串缓冲的长度,一般255;
API的第六参数是INI文件的路径。
GetPrivateProfileString("节名","Name","没有获得匹配",s,len(s),你那ini的路径);
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.IO;
namespace 读写ini文件
{
public class Ini
{
// 声明INI文件的写操作函数 WritePrivateProfileString()
[System.Runtime.InteropServices.DllImport("kernel32")]
private static extern long WritePrivateProfileString(string section, string key, string val, string filePath);
// 声明INI文件的读操作函数 GetPrivateProfileString()
[System.Runtime.InteropServices.DllImport("kernel32"