-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathIniEditor.cs
More file actions
37 lines (31 loc) · 1.12 KB
/
IniEditor.cs
File metadata and controls
37 lines (31 loc) · 1.12 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
using System;
using System.Collections.Generic;
using System.Linq;
using System.Runtime.InteropServices;
using System.Text;
using System.Threading.Tasks;
namespace FSR3ModSetupUtilityEnhanced
{
internal class IniEditor
{
public string Path{ get; private set; }
[DllImport("kernel32", CharSet = CharSet.Unicode)]
static extern long WritePrivateProfileString(string section, string key, string value, string filePath);
[DllImport("kernel32", CharSet = CharSet.Unicode)]
static extern int GetPrivateProfileString(string section, string key, string defaultValue, StringBuilder retVal, int size, string filePath);
public IniEditor(string path)
{
Path = path;
}
public void Write(string section, string key, string value)
{
WritePrivateProfileString(section, key, value, Path);
}
public string Read(string section, string key)
{
var retVal = new StringBuilder(255);
GetPrivateProfileString(section, key, "", retVal, 255, Path);
return retVal.ToString();
}
}
}