You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
66 lines
2.4 KiB
66 lines
2.4 KiB
using System; |
|
using System.Collections.Generic; |
|
using System.Linq; |
|
using System.Runtime.InteropServices; |
|
using System.Text; |
|
using System.Threading.Tasks; |
|
|
|
namespace INI |
|
{ |
|
public class IniFile |
|
{ |
|
[DllImport("kernel32.dll")] |
|
private extern static int GetPrivateProfileString(String AppName, String KeyName, String Default, StringBuilder ReturnedString, UInt32 Size, String FileName); |
|
[DllImport("kernel32.dll")] |
|
private extern static int WritePrivateProfileString(String AppName, String KeyName, String Str, String FileName); |
|
public IniFile(string filename) |
|
{ |
|
IniFileName = filename; |
|
} |
|
public String IniFileName |
|
{ |
|
get; |
|
set; |
|
} |
|
public String _GetString(String section, String key) |
|
{ |
|
StringBuilder s1 = new StringBuilder(128); |
|
GetPrivateProfileString(section, key, "", s1, 128, IniFileName); |
|
return s1.ToString(); |
|
} |
|
public Int64 _GetInt(String section, String key) |
|
{ |
|
StringBuilder s1 = new StringBuilder(100); |
|
GetPrivateProfileString(section, key, "", s1, 100, IniFileName); |
|
return Int64.Parse(s1.ToString()); |
|
} |
|
public Boolean _GetBool(String section, String key) |
|
{ |
|
StringBuilder s1 = new StringBuilder(100); |
|
GetPrivateProfileString(section, key, "", s1, 100, IniFileName); |
|
return Boolean.Parse(s1.ToString()); |
|
} |
|
public Double _GetDouble(String section, String key) |
|
{ |
|
StringBuilder s1 = new StringBuilder(100); |
|
GetPrivateProfileString(section, key, "", s1, 100, IniFileName); |
|
return Double.Parse(s1.ToString()); |
|
} |
|
public void _SetString(String section, String key, String val) |
|
{ |
|
WritePrivateProfileString(section, key, val, IniFileName); |
|
} |
|
public void _SetInt(String section, String key, Int64 val) |
|
{ |
|
WritePrivateProfileString(section, key, val.ToString(), IniFileName); |
|
} |
|
public void _SetDouble(String section, String key, Double val) |
|
{ |
|
WritePrivateProfileString(section, key, val.ToString(), IniFileName); |
|
} |
|
public void _SetBool(String section, String key, Boolean val) |
|
{ |
|
WritePrivateProfileString(section, key, val.ToString(), IniFileName); |
|
} |
|
} |
|
}
|
|
|