windows-nt/Source/XPSP1/NT/shell/ext/cscui/pin/error.cpp
2020-09-26 16:20:57 +08:00

53 lines
1 KiB
C++

//+-------------------------------------------------------------------------
//
// Microsoft Windows
//
// Copyright (C) Microsoft Corporation, 2000
//
// File: cscpin.cpp
//
//--------------------------------------------------------------------------
#include "pch.h"
#pragma hdrstop
#include "error.h"
CWinError::CWinError(
DWORD dwError
)
{
_Initialize(dwError, false);
}
CWinError::CWinError(
HRESULT hr
)
{
_Initialize(DWORD(hr), true);
}
void
CWinError::_Initialize(
DWORD dwError,
bool bHResult
)
{
if (0 == FormatMessageW(FORMAT_MESSAGE_FROM_SYSTEM,
NULL,
dwError,
0,
(LPWSTR)m_szText,
ARRAYSIZE(m_szText),
NULL))
{
LPCTSTR pszFmt = L"Error code %d";
if (bHResult)
{
pszFmt = L"Error code 0x%08X";
}
wnsprintf(m_szText, ARRAYSIZE(m_szText), pszFmt, dwError);
}
}