?? rcerrormessage.cpp
字號:
// //
// Created by Ozzy Osbourne(maojun) . HangZhou . 20030214 //
// //
//////////////////////////////////////////////////////////////////////////////
// CRcErrorMessage is format run time error message.
//
// Expect bugs.
//
// Please use and enjoy. Please let me know of any bugs/mods/improvements
// that you have found/implemented and I will fix/incorporate them into this file.
// Please send report to OzzyJMalmsteen@yahoo.com.cn or Ozzman@163.net
#include "stdafx.h"
#include "RcMSSQL.h"
#include "RcErrorMessage.h"
// Stardard headers
#include <lmerr.h>
#ifdef _DEBUG
#undef THIS_FILE
static char THIS_FILE[]=__FILE__;
#define new DEBUG_NEW
#endif
//////////////////////////////////////////////////////////////////////
// Construction/Destruction
//////////////////////////////////////////////////////////////////////
CRcErrorMessage::CRcErrorMessage()
{
m_strErrorMessage = _T("");
}
CRcErrorMessage::~CRcErrorMessage()
{
}
BOOL CRcErrorMessage::FormatErrorMessage(LPCTSTR lpszStep, DWORD dwLastError)
{
// Format message flags.
DWORD dwFormatFlags = FORMAT_MESSAGE_ALLOCATE_BUFFER |
FORMAT_MESSAGE_IGNORE_INSERTS |
FORMAT_MESSAGE_FROM_SYSTEM ;
// Default to system source.
HMODULE hModule = NULL;
// If dwLastError is in the network range, load the message source.
if (dwLastError >= NERR_BASE && dwLastError <= MAX_NERR)
{
hModule = LoadLibraryEx (TEXT("netmsg.dll"), NULL, LOAD_LIBRARY_AS_DATAFILE);
if (hModule != NULL)
{
dwFormatFlags |= FORMAT_MESSAGE_FROM_HMODULE;
}
}
DWORD dwMessageSize;
LPSTR MessageBuffer;
// Call FormatMessage() to allow for message text to be acquired from the system or from the supplied module handle.
if (dwMessageSize = FormatMessage (
dwFormatFlags,
hModule, // Module to get message from (NULL == system)
dwLastError,
MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT), // Default language.
(LPSTR) &MessageBuffer,
0,
NULL
))
{
// Output message string on stderr.
// DWORD dwBytesWritten;
// WriteFile(GetStdHandle(STD_ERROR_HANDLE), MessageBuffer, dwMessageSize, &dwBytesWritten, NULL);
m_strErrorMessage.Format ("%s: %s", lpszStep, MessageBuffer);
// Free the buffer allocated by the system.
LocalFree (MessageBuffer);
}
else
{
m_strErrorMessage.Format ("%s: %u", lpszStep, dwLastError);
// ExitProcess(dwLastError);
return FALSE;
}
// If we loaded a message source, unload it.
if (hModule != NULL)
{
FreeLibrary (hModule);
}
// ExitProcess(dwLastError);
return TRUE;
}
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -