showErrorInfo

void showErrorInfo(UINT nErrCode, UINT nLine, LPCTSTR lpFuncName, UINT nType);

/**************************************************************** 
// FunctionName    :    showErrorInfo
// Function        :    显示错误信息
// Parameter       :   nErrCode    :错误码
                       nLine      :__LINE__    
                       lpFuncName     :函数名称
                       nType          :该参数控制错误信息显示方式

// Author      :    Lthis
// Create          :    2015-3-23 21:09:34 
// Checked         :    Lthis 2015-3-23 
****************************************************************/

void CLoadNtDriver::showErrorInfo(UINT nErrCode, UINT nLine, LPCTSTR lpFuncName, UINT nType){
    LPTSTR lpMsgBuf = NULL;
    TCHAR szMessage[256] = { 0 };
    TCHAR szCaption[32]  = { 0 };

    FormatMessage(0x1300, NULL, nErrCode, 0x400, (LPTSTR)&lpMsgBuf, 64, NULL);
    StringCchPrintf(szMessage, 256, _T("Error code:0x%X:%s
"), nErrCode, lpMsgBuf);
    StringCchPrintf(szCaption, 32, _T("%s (Error Line:%d)"), lpFuncName, nLine);
    StringCchCat(szMessage, 256+32+1, szCaption);

    switch (nType)
    {
    case 0:
        OutputDebugString(szMessage);
        break;
    case 1:
        MessageBox(NULL, szMessage, szCaption, 0);
        break;
    default:
        break;
    }
}

......

原文地址:https://www.cnblogs.com/Lthis/p/4361037.html