mirror of
https://gitea.tendokyu.moe/ppc/amnet.git
synced 2026-09-25 07:38:17 +03:00
37 lines
1.2 KiB
C#
37 lines
1.2 KiB
C#
using System;
|
|
using Windows.Win32;
|
|
using Windows.Win32.Foundation;
|
|
|
|
namespace AMNet.Server;
|
|
|
|
internal static class Config
|
|
{
|
|
private const string ConfigFileName = @".\segatools.ini";
|
|
|
|
internal const string IOSection = "aimeio";
|
|
|
|
static Config()
|
|
{
|
|
GameId = ReadKey(IOSection, "gameId", 4);
|
|
ServerName = ReadKey(IOSection, "serverName", 26, Environment.MachineName);
|
|
|
|
EnableAimeTxt = PInvoke.GetPrivateProfileInt(IOSection, "enableKeyboardMode", 1, ConfigFileName) > 0;
|
|
AimeTxtPath = ReadKey("aime", "aimePath", PInvoke.MAX_PATH, @"DEVICE\aime.txt");
|
|
}
|
|
|
|
public static string GameId { get; }
|
|
public static string ServerName { get; }
|
|
|
|
public static bool EnableAimeTxt { get; }
|
|
public static string AimeTxtPath { get; }
|
|
|
|
internal static unsafe string ReadKey(string section, string key, uint maxLength, string @default = null)
|
|
{
|
|
// +1 for null terminator
|
|
var buffer = stackalloc char[(int)maxLength + 1];
|
|
var bufferStr = new PWSTR(buffer);
|
|
|
|
PInvoke.GetPrivateProfileString(section, key, @default ?? string.Empty, bufferStr, maxLength + 1, ConfigFileName);
|
|
return bufferStr.ToString();
|
|
}
|
|
} |