抛弃GdCpp*.dll/pdb历史重新建库。libhv和Sqlite的dll保留
This commit is contained in:
44
include/CWinErr.h
Normal file
44
include/CWinErr.h
Normal file
@@ -0,0 +1,44 @@
|
||||
#ifndef CWINERR_H
|
||||
#define CWINERR_H
|
||||
|
||||
#include "GdCPP_Exports.h"
|
||||
#include <stdint.h>
|
||||
#include <xstring>
|
||||
|
||||
GDCPP_API wchar_t* getWinErrString(DWORD winErrCode);
|
||||
GDCPP_API DWORD getWinErrString(DWORD winErrCode, wchar_t* lpMsgBuf, DWORD nSize);
|
||||
|
||||
class GDCPP_API CWinErr
|
||||
{
|
||||
public:
|
||||
CWinErr(uint32_t bufsize=1024)
|
||||
: bufSize(bufsize)
|
||||
{
|
||||
pMsg = new wchar_t[bufSize];
|
||||
}
|
||||
|
||||
~CWinErr()
|
||||
{
|
||||
delete [] pMsg;
|
||||
}
|
||||
|
||||
/// 记录Windows API执行出错后用GetLastError()获取的错误码。
|
||||
uint32_t errCode=0;
|
||||
|
||||
wchar_t* pMsg = nullptr;
|
||||
uint32_t bufSize = 0;
|
||||
|
||||
DWORD GetLastError()
|
||||
{
|
||||
errCode = ::GetLastError();
|
||||
return getWinErrString(errCode, pMsg, bufSize);
|
||||
}
|
||||
|
||||
DWORD WSAGetLastError()
|
||||
{
|
||||
errCode = ::WSAGetLastError();
|
||||
return getWinErrString(errCode, pMsg, bufSize);
|
||||
}
|
||||
};
|
||||
|
||||
#endif // CWINERR_H
|
||||
Reference in New Issue
Block a user