errorhandling.cpp

来自「AES, 即Advanced Encryption Standard高级加密标准」· C++ 代码 · 共 56 行

CPP
56
字号
/*
 *  ErrorHandling.cpp
 *
 *  Copyright (C) 2007
 *  Paul E. Jones <paulej@arid.us>
 *  All Rights Reserved.
 *
 ******************************************************************************
 *  $Id: ErrorHandling.cpp,v 1.1 2007/05/14 10:41:43 paulej Exp $
 ******************************************************************************
 *
 *  This file defines various global error handling and reporting functions.
 *
 */

#include "stdafx.h"

/*
 * ReportError
 *
 * Report an error to the user
 */
void ReportError(	std::basic_string<TCHAR> message,
					DWORD reason)
{
    LPTSTR error_string;

    if (reason != ERROR_SUCCESS)
    {
        if (::FormatMessage(FORMAT_MESSAGE_ALLOCATE_BUFFER |
                    FORMAT_MESSAGE_FROM_SYSTEM,
                    NULL,
                    reason,
                    0,
                    (LPTSTR)&error_string,
                    0,
                    NULL) != 0)
        {
            LPTSTR p = _tcschr(error_string, _T('\r'));
            if(p != NULL)
            {
                *p = _T('\0');
            }

            message += _T(":\n");
            message += error_string;

            ::LocalFree(error_string);
        }
    }

    ::MessageBox(NULL,message.c_str(),_T("AES Crypt Error"), MB_OK);
}


⌨️ 快捷键说明

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