- /*
- * 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;
- }
- //该片段来自于http://www.codesnippet.cn/detail/291120137604.html
来源: http://www.codesnippet.cn/detail/291120137604.html