From the Windows via C/C++ book:
Ok, I try to get any system error code by Microsoft and to analize its fields:
HANDLE hMutex = OpenMutex(0, FALSE, _T("12345")); // some unexisting object if (NULL == hMutex) { DWORD errCode = GetLastError(); // I get 0x00000002 here PTSTR msg = NULL; LCID langId = MAKELANGID(LANG_NEUTRAL, SUBLANG_NEUTRAL); DWORD result = FormatMessage(FORMAT_MESSAGE_ALLOCATE_BUFFER | FORMAT_MESSAGE_FROM_SYSTEM | FORMAT_MESSAGE_IGNORE_INSERTS, NULL, errCode, langId, (PTSTR)&msg, 0, NULL); wcerr << msg << endl; return 2; } My errCode value is 0x00000002, but I expected it will have the severinity field as 3 (error) and some value of the facility code field...
Why the gotten result has not the values in these fields?
