[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 void SetIni(string section, string key, string val)
{
SetIni(section, key, val, Path.GetDirectoryName(Application.ExecutablePath) + @"\config.ini");
}
public void SetIni(string section, string key, string val, string filePath)
{
WritePrivateProfileString(section, key, val, filePath);
}
public string GetIni(string section, string key)
{
return GetIni(section, key, "", 1024, Path.GetDirectoryName(Application.ExecutablePath) + @"\config.ini");
}
public string GetIni(string section, string key, string def, int size, string filePath)
{
string re = "";
StringBuilder retVal = new StringBuilder(1024);
GetPrivateProfileString(section, key, def, retVal, size, filePath);
re = retVal.ToString();
return re;
}
'C#' 카테고리의 다른 글
| C# .NET 사용자 정의 컨트롤 만들기 (1) | 2024.01.25 |
|---|---|
| C# 파일 열기 (0) | 2021.06.10 |
| C# 파일 저장 (0) | 2021.06.10 |
| C# MdiChildren 폼 호출시 화면 깜빡이는현상 (0) | 2021.03.12 |
| C# MdiChildren 폼 호출 (0) | 2021.03.12 |