When we donot know the reason why the statement is failing. Then call below function:
DWORD errorCode=GetLastError();
Above function will return an error code. We can translate that code into string as below.
TCHAR errorMessage[1024] = TEXT("");
DWORD flags = FORMAT_MESSAGE_FROM_SYSTEM
| FORMAT_MESSAGE_IGNORE_INSERTS
| FORMAT_MESSAGE_MAX_WIDTH_MASK;
FormatMessage( flags,
NULL,
errorCode,
MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT),
errorMessage,
sizeof(errorMessage)/sizeof(TCHAR),
NULL );
No comments:
Post a Comment