forked from shiftwinting/FastGithub
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
2 changed files
with
45 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
using System; | ||
using System.Runtime.InteropServices; | ||
using System.Runtime.Versioning; | ||
|
||
namespace FastGithub | ||
{ | ||
static class ConsoleUtil | ||
{ | ||
private const uint ENABLE_QUICK_EDIT = 0x0040; | ||
|
||
private const int STD_INPUT_HANDLE = -10; | ||
|
||
[DllImport("kernel32.dll", SetLastError = true)] | ||
[SupportedOSPlatform("windows")] | ||
private static extern IntPtr GetStdHandle(int nStdHandle); | ||
|
||
[DllImport("kernel32.dll", SetLastError = true)] | ||
[SupportedOSPlatform("windows")] | ||
private static extern bool GetConsoleMode(IntPtr hConsoleHandle, out uint lpMode); | ||
|
||
[DllImport("kernel32.dll", SetLastError = true)] | ||
[SupportedOSPlatform("windows")] | ||
private static extern bool SetConsoleMode(IntPtr hConsoleHandle, uint dwMode); | ||
|
||
/// <summary> | ||
/// 禁用快速编辑模式 | ||
/// </summary> | ||
/// <returns></returns> | ||
public static bool DisableQuickEdit() | ||
{ | ||
if (OperatingSystem.IsWindows()) | ||
{ | ||
var hwnd = GetStdHandle(STD_INPUT_HANDLE); | ||
if (GetConsoleMode(hwnd, out uint mode)) | ||
{ | ||
mode &= ~ENABLE_QUICK_EDIT; | ||
return SetConsoleMode(hwnd, mode); | ||
} | ||
} | ||
|
||
return false; | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters