在Windows中,是否可以将errno转换为HRESULT? [英] In Windows, is there any way to convert an errno into an HRESULT?

查看:154
本文介绍了在Windows中,是否可以将errno转换为HRESULT?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我知道 HRESULT_FROM_WIN32 宏可以将Win32错误代码转换为HRESULT,有什么方法可以从 errno 错误?

解决方案

总之,没有。



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


errno值是在
各种错误情况下分配给errno的常量。



ERRNO.H包含errno值的定义。但是,并非所有的
ERRNO.H中给出的定义都在运行
系统的32位Windows中使用。 ERRNO.H中的某些值用于维护
与UNIX系列操作系统的兼容性。



在32位Windows操作系统中的errno值系统是XENIX系统中errno值的
的子集。 因此,errno值不一定与Windows操作系统的系统
调用返回的实际错误代码相同,为
。要访问实际的
操作系统错误代码,请使用_doserrno变量,其中
包含此值。


当然,您可以使用开关盒来编写自己的函数,这些开关盒将翻译错误代码。



您可以看到在窗口上定义了大约80个errno值。 / p>

I know the HRESULT_FROM_WIN32 macro to convert a Win32 error code into an HRESULT, is there any way to do the conversion starting from an errno error?

解决方案

In short, no.

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

The errno values are constants assigned to errno in the event of various error conditions.

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

The errno values in a 32-bit Windows operating system are a subset of the values for errno in XENIX systems. Thus, the errno value is not necessarily the same as the actual error code returned by a system call from the Windows operating systems. To access the actual operating system error code, use the _doserrno variable, which contains this value.

Of course you can write your own function with switch-cases which will "translate" error codes.

You can see that there are about 80 errno values defined on windows.

这篇关于在Windows中,是否可以将errno转换为HRESULT?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆