将NtStatus code转换成Win32 Error
/* * This is an alternative to the RtlNtStatusToDosError() * function in ntdll.dll. It uses the GetOverlappedResult() * function in kernel32.dll to do the conversion. */ #include <windows.h> DWORD ConvertNtStatusToWin32Error(LONG ntstatus) { DWORD oldError; DWORD result; DWORD br; OVERLAPPED o; o.Internal = ntstatus; o.InternalHigh = 0; o.Offset = 0; o.OffsetHigh = 0; o.hEvent = 0; oldError = GetLastError(); GetOverlappedResult(NULL, &o, &br, FALSE); result = GetLastError(); SetLastError(oldError); return result; }