How do I retrieve an error string from WSAGetLastError()?

后端 未结 3 953
猫巷女王i
猫巷女王i 2020-12-16 09:59

I\'m porting some sockets code from Linux to Windows.

In Linux, I could use strerror() to convert an errno code into a human-readable string.

MS

3条回答
  •  长情又很酷
    2020-12-16 10:53

    As the documentation for WSAGetLastError says you can use FormatMessage to obtain a text version of the error message.

    You need to set FORMAT_MESSAGE_FROM_SYSTEM in the dwFlags parameter and pass the error code as the dwMessage parameter.

提交回复
热议问题