for Push.
This commit is contained in:
@@ -0,0 +1,53 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Runtime.InteropServices;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace KssSmaPlaLib.Ini
|
||||
{
|
||||
public static class IniHelper
|
||||
{
|
||||
private const string INI_PATH = @".\Settings.ini";
|
||||
|
||||
// Win32 API宣言
|
||||
[DllImport("kernel32.dll", CharSet = CharSet.Unicode)]
|
||||
private static extern int GetPrivateProfileString(
|
||||
string lpAppName,
|
||||
string lpKeyName,
|
||||
string lpDefault,
|
||||
StringBuilder lpReturnedString,
|
||||
int nSize,
|
||||
string lpFileName);
|
||||
|
||||
[DllImport("kernel32.dll", CharSet = CharSet.Unicode)]
|
||||
private static extern bool WritePrivateProfileString(
|
||||
string lpAppName,
|
||||
string lpKeyName,
|
||||
string lpString,
|
||||
string lpFileName);
|
||||
|
||||
/// <summary>
|
||||
/// INIファイルから値を読み込み(セクション+キー指定)
|
||||
/// </summary>
|
||||
public static string ReadValue(string? iniPath, string section, string key, string defaultValue = "")
|
||||
{
|
||||
if (string.IsNullOrEmpty(iniPath)) iniPath = INI_PATH;
|
||||
var sb = new StringBuilder(1024);
|
||||
GetPrivateProfileString(section, key, defaultValue, sb, sb.Capacity, iniPath);
|
||||
var str = sb.ToString();
|
||||
str = string.IsNullOrEmpty(str) ? defaultValue : str;
|
||||
return str;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// INIファイルに値を書き込み(セクション+キー+値指定)
|
||||
/// </summary>
|
||||
public static bool WriteValue(string iniPath, string section, string key, string value)
|
||||
{
|
||||
if (string.IsNullOrEmpty(iniPath)) iniPath = INI_PATH;
|
||||
return WritePrivateProfileString(section, key, value, iniPath);
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user