将framework版本 从4.8 降低到4.6.2;

修复控制台初始化隐藏有几率无效的BUG
This commit is contained in:
梅浩东
2023-11-16 09:26:40 +08:00
parent ba46b2e533
commit 746f06f7dc
12 changed files with 81 additions and 50 deletions
+28 -2
View File
@@ -37,6 +37,30 @@ namespace BarrageGrab
}
/// <summary>
/// 隐藏/显示 控制台
/// </summary>
/// <param name="show"></param>
public static void DisplayConsole(bool show)
{
//var hWnd = WinApi.FindWindow(null, Console.Title);
var hWnd = WinApi.GetConsoleWindow();
if (hWnd != IntPtr.Zero)
{
WinApi.ShowWindow(hWnd, show? WinApi.CmdShow.SW_SHOW:WinApi.CmdShow.SW_HIDE);
}
}
public static void DisplayConsoleByTitle(bool show)
{
var hWnd = WinApi.FindWindow(null, Console.Title);
//var hWnd = WinApi.GetConsoleWindow();
if (hWnd != IntPtr.Zero)
{
WinApi.ShowWindow(hWnd, show ? WinApi.CmdShow.SW_SHOW : WinApi.CmdShow.SW_HIDE);
}
}
/// <summary>
/// 房间缓存管理器
/// </summary>
@@ -95,7 +119,8 @@ namespace BarrageGrab
/// <returns></returns>
public long GetCachedWebRoomid(string roomid)
{
if (RoomInfoCache.TryGetValue(roomid, out var value)) return long.Parse(value.WebRoomId??"-1");
RoomInfo value;
if (RoomInfoCache.TryGetValue(roomid,out value)) return long.Parse(value.WebRoomId??"-1");
return -1;
}
@@ -106,7 +131,8 @@ namespace BarrageGrab
/// <returns></returns>
public RoomInfo GetCachedWebRoomInfo(string roomid)
{
if (RoomInfoCache.TryGetValue(roomid, out var value)) return value;
RoomInfo value;
if (RoomInfoCache.TryGetValue(roomid, out value)) return value;
return null;
}
}