C # implements reading and writing values in the INI File
/** // Declare the API function for reading and writing the INI File
[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 );
/** // <Summary>
/// Write the INI File
/// </Summary>
/// <Param name = "Section"> </param>
/// <Param name = "Key"> </param>
/// <Param name = "Value"> </param>
Public static void IniWriteValue (string path, string Section, string Key, string Value)
{
WritePrivateProfileString (Section, Key, Value, path );
}
/** // <Summary>
/// Read the specified INI File
/// </Summary>
/// <Param name = "Section"> </param>
/// <Param name = "Key"> </param>
/// <Returns> </returns>
Public static string IniReadValue (string path, string Section, string Key)
{
StringBuilder temp = new StringBuilder (255 );
Int I = GetPrivateProfileString (Section, Key, "", temp, 255, path );
Return temp. ToString ();
}