mirror of
https://github.com/microsoft/PowerToys.git
synced 2025-12-16 19:57:57 +01:00
Remove redundancy
This commit is contained in:
@@ -48,14 +48,10 @@ namespace Espresso.Shell.Core
|
|||||||
[return: MarshalAs(UnmanagedType.Bool)]
|
[return: MarshalAs(UnmanagedType.Bool)]
|
||||||
private static extern bool AllocConsole();
|
private static extern bool AllocConsole();
|
||||||
|
|
||||||
[DllImport("kernel32.dll", SetLastError = true)]
|
|
||||||
public static extern IntPtr GetStdHandle(int nStdHandle);
|
|
||||||
|
|
||||||
[DllImport("kernel32.dll", SetLastError = true)]
|
[DllImport("kernel32.dll", SetLastError = true)]
|
||||||
public static extern bool SetStdHandle(int nStdHandle, IntPtr hHandle);
|
public static extern bool SetStdHandle(int nStdHandle, IntPtr hHandle);
|
||||||
|
|
||||||
[DllImport("kernel32.dll", CharSet = CharSet.Auto, SetLastError = true)]
|
[DllImport("kernel32.dll", CharSet = CharSet.Auto, SetLastError = true)]
|
||||||
|
|
||||||
public static extern IntPtr CreateFile([MarshalAs(UnmanagedType.LPTStr)] string filename,
|
public static extern IntPtr CreateFile([MarshalAs(UnmanagedType.LPTStr)] string filename,
|
||||||
[MarshalAs(UnmanagedType.U4)] uint access,
|
[MarshalAs(UnmanagedType.U4)] uint access,
|
||||||
[MarshalAs(UnmanagedType.U4)] FileShare share,
|
[MarshalAs(UnmanagedType.U4)] FileShare share,
|
||||||
@@ -74,13 +70,10 @@ namespace Espresso.Shell.Core
|
|||||||
{
|
{
|
||||||
AllocConsole();
|
AllocConsole();
|
||||||
|
|
||||||
var outputHandle = GetStdHandle(StdOutputHandle);
|
|
||||||
var outputFilePointer = CreateFile("CONOUT$", GenericRead | GenericWrite, FileShare.Write, IntPtr.Zero, FileMode.OpenOrCreate, 0, IntPtr.Zero);
|
var outputFilePointer = CreateFile("CONOUT$", GenericRead | GenericWrite, FileShare.Write, IntPtr.Zero, FileMode.OpenOrCreate, 0, IntPtr.Zero);
|
||||||
if (outputFilePointer != outputHandle)
|
|
||||||
{
|
SetStdHandle(StdOutputHandle, outputFilePointer);
|
||||||
SetStdHandle(StdOutputHandle, outputFilePointer);
|
Console.SetOut(new StreamWriter(Console.OpenStandardOutput(), Console.OutputEncoding) { AutoFlush = true });
|
||||||
Console.SetOut(new StreamWriter(Console.OpenStandardOutput(), Console.OutputEncoding) { AutoFlush = true });
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
|||||||
Reference in New Issue
Block a user