⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 winexception.cpp

📁 c+++ game uploading now
💻 CPP
字号:
/**
 @file
 Implements the Win::Exception class.
*/

#include "WinException.h"

using namespace Win;

char const Exception::msgFormat[]=
   "Problem: %s\noperating system tells us: %s";

void Exception::Show() const
{
    char *buf;
    char *sysMsg;

    ::FormatMessage(FORMAT_MESSAGE_ALLOCATE_BUFFER|FORMAT_MESSAGE_FROM_SYSTEM,
                    NULL,
                    _err,
                    MAKELANGID(LANG_NEUTRAL, 
                    SUBLANG_DEFAULT), // Default language
                    (LPTSTR) &sysMsg,
                    0,
                    NULL);

    //???BUG???: what if this is an "out of memory" exception?
    buf = new char[strlen (sysMsg) + strlen (_msg) + strlen (msgFormat) + 1];
    
    wsprintf(buf, msgFormat, _msg, sysMsg);
    ::MessageBox(0, buf, "Error", MB_ICONEXCLAMATION|MB_OK);

    // Free the buffer.
    ::LocalFree (sysMsg);
    delete buf;
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -