chino icon

Translate error code into string

chino | PRO | 08/18/17 04:53:03 PM UTC | 0 ⭐ | 10380 👁️ | Never ⏰ | []
C++ (WinAPI) |

0 B

|

None

|

0 👍

/

0 👎

void LErr(TCHAR szFunc[] = NULL, DWORD dwErr = 0)
{
    /*
        szFunc ... Function Name
        dwErr ... Error Code (it ccan be obtained by GetLastError() or sth)
    */
 
    LPVOID lpMsgBuf;
    TCHAR szMsg[4096] = { '\0' };
 
    FormatMessage(FORMAT_MESSAGE_ALLOCATE_BUFFER | FORMAT_MESSAGE_FROM_SYSTEM |
        FORMAT_MESSAGE_IGNORE_INSERTS, NULL, dwErr,
        MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT),
        (LPTSTR)&lpMsgBuf, 0, NULL);
 
    swprintf_s(szMsg, 4096, _T("%s\r\n0x%08X (Dec:%u)"), lpMsgBuf, dwErr, dwErr);
    
    //MessageBox(NULL, szMsg, NULL, MB_OK);
}

Comments

  •  icon
    01/01/70 12:00:00 AM UTC
    Plain Text |

    0 B

    |

    👍

    /

    👎

    
        
  •  icon
    01/01/70 12:00:00 AM UTC
    Plain Text |

    0 B

    |

    👍

    /

    👎