using System; using System.Runtime.InteropServices; using System.Text; class MainClass { [DllImport("kernel32.dll", EntryPoint = "WritePrivateProfileString")] private static extern bool WritePrivateProfileString(string lpAppName, string lpKeyName, string lpString, string lpFileName); static void Main(string[] args) { // Write a new value. WritePrivateProfileString("MySection", "MyKey", "New Value", "\\initest.ini"); } }