forked from crosire/reshade
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathIniFile.cs
22 lines (20 loc) · 929 Bytes
/
IniFile.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
using System.Text;
using System.Runtime.InteropServices;
public static class IniFile
{
[DllImport("kernel32", CharSet = CharSet.Unicode)]
private static extern int GetPrivateProfileString(string section, string key, string defaultValue, StringBuilder value, int size, string filePath);
[DllImport("kernel32", CharSet = CharSet.Unicode, SetLastError = true)]
[return: MarshalAs(UnmanagedType.Bool)]
private static extern bool WritePrivateProfileString(string section, string key, string value, string filePath);
public static string ReadValue(string file, string section, string key, string defaultValue = "")
{
var value = new StringBuilder(512);
GetPrivateProfileString(section, key, defaultValue, value, value.Capacity, file);
return value.ToString();
}
public static bool WriteValue(string file, string section, string key, string value)
{
return WritePrivateProfileString(section, key, value, file);
}
}