TSR_Loader/Transformers2_Launcher/INIFile.cs
2024-07-07 09:22:24 +02:00

39 lines
1.2 KiB
C#

using System.IO;
using System.Runtime.InteropServices;
using System.Text;
namespace Transformers2_Launcher
{
#region INI class
public class INIFile
{
private string _RelativePath = string.Empty;
public FileInfo FInfo { get; private set; }
[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);
public INIFile(string INIPath)
{
_RelativePath = INIPath;
FInfo = new FileInfo(_RelativePath);
}
public long IniWriteValue(string Section, string Key, string Value)
{
return WritePrivateProfileString(Section, Key, Value, this._RelativePath);
}
public string IniReadValue(string Section, string Key)
{
StringBuilder temp = new StringBuilder(255);
int i = GetPrivateProfileString(Section, Key, "", temp, 255, this._RelativePath);
return temp.ToString();
}
}
#endregion
}