On Windows, is there a way to convert errno to HRESULT?

I know the HRESULT_FROM_WIN32 macro for converting Win32 error code to HRESULT, is there a way to do the conversion starting with errno error?

+6
source share
1 answer

In short, no.

From http://msdn.microsoft.com/en-us/library/5814770t%28v=vs.100%29.aspx

Errno values ​​are constants assigned by errno in case of various error conditions.

ERRNO.H contains errno value definitions. However, not all definitions given in ERRNO.H are used in the 32-bit Windows operating system. Some of the values ​​in ERRNO.H are present to maintain compatibility with the UNIX family of operating systems.

Errno values ​​on a 32-bit Windows operating system are a subset of errno values ​​on XENIX systems. Therefore, the errno value does not necessarily match the actual error code returned by the system call from Windows operating systems . To access the operating system error code, use the variable _doserrno, which contains this value.

Of course, you can write your own function with wiring closets that will "translate" error codes.

You can see that about 80 errno values ​​are defined in the windows.

+5
source

Source: https://habr.com/ru/post/925026/


All Articles