一个C++的错误报告类(原创)

一个错误报告类(原创)

by 头发抽筋

一个错误报告类,支持Unicode和ASCII的错误报告,支持可变参数列表,比较好用


#ifndef _ERROR_REPORT_H_

#define _ERROR_REPORT_H_

#include 
"windows.h"
#include 
"stdio.h"
#include 
"stdarg.h"
#include 
"tchar.h"

class CErrorReport
{
public:
    
void Error(const LPCWSTR error,  );
    
void Error(const char* error,  );
};

#endif


#include "errorReport.h"


void CErrorReport::Error(LPCWSTR error,  )
{
    va_list argptr;
    WCHAR text[
1024];
    WCHAR text2[
1024];

    va_start (argptr, error);
    wvsprintf (text, error, argptr);
    va_end (argptr);

    wsprintf (text2, L
"%s\n", text);
    MessageBox (NULL, LPCWSTR(text2), L
"Error", MB_OK);
    exit(
1);
}

void CErrorReport::Error(const char* error,  )
{
    va_list argptr;
    
char text[1024];
    
char text2[1024];

    va_start (argptr, error);
    vsprintf (text, error, argptr);
    va_end (argptr);

    sprintf (text2, 
"%s\n", text);
    MessageBoxA (NULL, text2, 
"Error", MB_OK);
    exit(
1);

posted @ 2008-09-19 11:18  头发抽筋  阅读(435)  评论(0)    收藏  举报