Files
ppc_amnet/AMNet.Server/Config.cs
T

31 lines
883 B
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);
}
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();
}
}