forked from iodes/GSharp
-
Notifications
You must be signed in to change notification settings - Fork 4
/
INI.cs
43 lines (37 loc) · 1.09 KB
/
INI.cs
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
38
39
40
41
42
43
using System.Text;
using System.Runtime.InteropServices;
namespace GSharp.Manager
{
internal class INI
{
private string Path;
public INI(string Path)
{
this.Path = Path;
}
[DllImport("kernel32.dll")]
private static extern int GetPrivateProfileString(
string section,
string key,
string def,
StringBuilder retVal,
int size,
string filePath);
[DllImport("kernel32.dll")]
private static extern long WritePrivateProfileString(
string section,
string key,
string val,
string filePath);
public string GetValue(string Section, string Key)
{
StringBuilder temp = new StringBuilder(255);
int i = GetPrivateProfileString(Section, Key, "", temp, 255, Path);
return temp.ToString();
}
public void SetValue(string Section, string Key, string Value)
{
WritePrivateProfileString(Section, Key, Value, Path);
}
}
}