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

📄 winexcept.h

📁 c++系统开发实例精粹内附的80例源代码 环境:windows2000,c++6.0
💻 H
字号:
//////////////////////////////////////////////////////////////////////
// FileFury
// Copyright (c) 2000 Tenebril Incorporated
// All rights reserved.
//
// This source code is governed by the Tenebril open source
// license (http://www.tenebril.com/developers/opensource/license.html)
//
// For more information on this and other open source applications,
// visit the Tenebril OpenSource page:
//       http://www.tenebril.com/developers/opensource
//
//////////////////////////////////////////////////////////////////////

#if !defined WINEX_H
#define WINEX_H

#include <windows.h>

char const msgFormat[] = "Our problem: %s\nSystem tells us: %s";
 
class WinException
{
public:
    WinException (char* msg)
    : _err (GetLastError()), _msg(msg)
    {}
    void Display () 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 
                     );
        buf = new char [strlen (sysMsg) + strlen (_msg) + strlen (msgFormat) + 1];
        wsprintf ( buf, msgFormat, _msg, sysMsg );
        MessageBox (0, buf, "Exception", MB_ICONEXCLAMATION | MB_OK);

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

    DWORD GetError () const { return _err; }

private:
    DWORD _err;
    char* _msg;
};

#endif

⌨️ 快捷键说明

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