moved readconsoleinputstream to samples folder; added readme; updated root readme.

This commit is contained in:
oising
2019-04-29 14:50:38 -04:00
parent 2e0fd58bc5
commit 987805ebaf
8 changed files with 17 additions and 0 deletions

View File

@@ -0,0 +1,31 @@
using System;
using System.Diagnostics;
using System.Runtime.InteropServices;
namespace Samples.Terminal
{
internal static class NativeMethods
{
private static int MakeHRFromErrorCode(int errorCode)
{
// Don't convert it if it is already an HRESULT
if ((0xFFFF0000 & errorCode) != 0)
{
Debug.Assert(false, "errorCode is already HRESULT");
return errorCode;
}
return unchecked(((int)0x80070000) | errorCode);
}
internal static Exception GetExceptionForWin32Error(int errorCode)
{
return Marshal.GetExceptionForHR(MakeHRFromErrorCode(errorCode));
}
internal static Exception GetExceptionForLastWin32Error()
{
return GetExceptionForWin32Error(Marshal.GetLastWin32Error());
}
}
}