move card storage/web server handlers to separate files

This commit is contained in:
ppc
2024-09-02 14:14:02 +01:00
parent 31354bd146
commit ec98003d2c
4 changed files with 211 additions and 151 deletions
+31
View File
@@ -0,0 +1,31 @@
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);
}
public static string GameId { get; }
public static string ServerName { get; }
internal static unsafe string ReadKey(string section, string key, uint maxLength, string @default = null)
{
var buffer = stackalloc char[(int)maxLength + 1];
var bufferStr = new PWSTR(buffer);
PInvoke.GetPrivateProfileString(section, key, @default ?? string.Empty, bufferStr, maxLength, ConfigFileName);
return bufferStr.ToString();
}
}