Replace GetLastError

pull/362/head
NextTurn 2018-12-02 00:00:00 +08:00
parent 3bb10ab60d
commit f1036e613b
No known key found for this signature in database
GPG Key ID: 17A0D50ADDE1A0C4
3 changed files with 2 additions and 6 deletions

View File

@ -195,7 +195,7 @@ namespace winsw.Native
if (!result)
{
winErrorCode = Kernel32.GetLastError();
winErrorCode = Marshal.GetLastWin32Error();
Console.WriteLine("LookupAccountName failed: " + winErrorCode);
}
else

View File

@ -24,9 +24,6 @@ namespace winsw.Native
string? lpCurrentDirectory,
[In] ref STARTUPINFO lpStartupInfo,
out PROCESS_INFORMATION lpProcessInformation);
[DllImport("kernel32.dll")]
public static extern int GetLastError();
}
[StructLayout(LayoutKind.Sequential)]

View File

@ -2,7 +2,6 @@
using System.Diagnostics;
using System.Runtime.InteropServices;
using log4net;
using winsw.Native;
namespace winsw.Util
{
@ -57,7 +56,7 @@ namespace winsw.Util
bool success = FreeConsole();
if (!success)
{
long errorCode = Kernel32.GetLastError();
long errorCode = Marshal.GetLastWin32Error();
Logger.Warn("Failed to detach from console. Error code: " + errorCode);
}