-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathWindowsInterops.cs
More file actions
28 lines (23 loc) · 901 Bytes
/
WindowsInterops.cs
File metadata and controls
28 lines (23 loc) · 901 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
using System.Runtime.InteropServices;
namespace BlazorStandaloneApplicationExample
{
public static class WindowsInterops
{
public const int GWL_EXSTYLE = -20;
public const int WS_EX_TOOLWINDOW = 0x00000080;
public const int SW_HIDE = 0;
public const int SW_SHOW = 5;
[DllImport("kernel32.dll")]
public static extern IntPtr GetConsoleWindow();
[DllImport("user32.dll")]
public static extern int SetWindowLong(IntPtr hWnd, int nIndex, uint dwNewLong);
[DllImport("user32.dll")]
public static extern bool ShowWindow(IntPtr hWnd, int nCmdShow);
public static void HideConsoleWindow()
{
var consoleWindow = GetConsoleWindow();
ShowWindow(consoleWindow, WindowsInterops.SW_HIDE);
SetWindowLong(consoleWindow, GWL_EXSTYLE, WS_EX_TOOLWINDOW);
}
}
}