开发笔记
Windows下格式化显示错误码 使用FormatMessage函数 TCHAR *s = NULL; FormatMessage(FORMAT_MESSAGE_ALLOCATE_BUFFER | FORMAT_MESSAGE_FROM_SYSTEM | FORMAT_MESSAGE_IGNORE_INSERTS, NULL, WSAGetLastError(), MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT), (LPTSTR) &s, 0, NULL); OutputDebugString(s); 中文环境下打印: 由于目标计算机积极拒绝,无法连接。 参考 https://stackoverflow.com/questions/3400922/how-do-i-retrieve-an-error-string-from-wsagetlasterror > https://docs.microsoft.com/zh-cn/windows/win32/api/winbase/nf-winbase-formatmessage?redirectedfrom=MSDN 多字节API和UNICODE API 采用Windows接口时, 如果使用宏定义的接口, 如OutputDebugString, 就要考虑到传参在多字节API和UNICODE API直间的兼容 ...