iniファイルから値を読み込むコードはこちらの記事を参照してください。
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using System.Runtime.InteropServices;
namespace InifileDemo
{
public partial class FormMain : Form
{
[DllImport("kernel32.dll", EntryPoint = "WritePrivateProfileStringW", CharSet = CharSet.Unicode, SetLastError = true)]
[return: MarshalAs(UnmanagedType.Bool)]
static extern bool WritePrivateProfileString(string lpAppName, string lpKeyName, string lpString, string lpFileName);
public FormMain()
{
InitializeComponent();
}
private void Button1_Click(object sender, EventArgs e)
{
bool ret = WritePrivateProfileString("TestSection", "TestKey", textBox2.Text, ".\\file.ini");
if (ret == true)
{
textBox1.Text = "OK";
}
}
}
}
using System.Runtime.InteropServices;
[DllImport("kernel32.dll", EntryPoint = "WritePrivateProfileStringW", CharSet = CharSet.Unicode, SetLastError = true)]
[return: MarshalAs(UnmanagedType.Bool)]
static extern bool WritePrivateProfileString(string lpAppName, string lpKeyName, string lpString, string lpFileName);
private void Button1_Click(object sender, EventArgs e)
{
bool ret = WritePrivateProfileString("TestSection", "TestKey", textBox2.Text, ".\\file.ini");
if (ret == true)
{
textBox1.Text = "OK";
}
}