libjmmcg
release_579_6_g8cffd
A C++ library containing an eclectic mix of useful, advanced components.
DumpWinMsg.hpp
Go to the documentation of this file.
1
/******************************************************************************
2
** Copyright © 2002 by J.M.McGuiness, coder@hussar.me.uk
3
**
4
** This library is free software; you can redistribute it and/or
5
** modify it under the terms of the GNU Lesser General Public
6
** License as published by the Free Software Foundation; either
7
** version 2.1 of the License, or (at your option) any later version.
8
**
9
** This library is distributed in the hope that it will be useful,
10
** but WITHOUT ANY WARRANTY; without even the implied warranty of
11
** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12
** Lesser General Public License for more details.
13
**
14
** You should have received a copy of the GNU Lesser General Public
15
** License along with this library; if not, write to the Free Software
16
** Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
17
*/
18
// DESCRIPTION:
19
// Function to convert a Windows error code to a string.
20
21
#
pragma
once
22
23
#
include
<
windows
.
h
>
24
#
include
<
tchar
.
h
>
25
#
include
<
string
>
26
27
namespace
jmmcg
{
namespace
NTUtils
{
28
29
#
ifndef
_TSTRING_DEF
30
#
define
_TSTRING_DEF
31
typedef
std
::
basic_string
<
TCHAR
,
std
::
char_traits
<
TCHAR
> >
tstring
;
32
#
endif
_TSTRING_DEF
33
34
// Handy-dandy function for turning windows error codes into strings...
35
inline
tstring
__fastcall
DumpWinMessage
(
const
unsigned
long
err_no
) {
36
TCHAR
*lpMsgBuf;
37
::FormatMessage(FORMAT_MESSAGE_ALLOCATE_BUFFER|FORMAT_MESSAGE_FROM_SYSTEM|FORMAT_MESSAGE_IGNORE_INSERTS,NULL,err_no,MAKELANGID(LANG_NEUTRAL,SUBLANG_DEFAULT),
reinterpret_cast
<
TCHAR
*>(&lpMsgBuf),0,NULL);
38
const
tstring str(lpMsgBuf ? lpMsgBuf :
_T
(
"No Windows message string available."
));
39
::LocalFree(lpMsgBuf);
40
return
str;
41
}
42
43
} }
experimental
NT-based
NTSpecific
DumpWinMsg.hpp
Generated on Tue May 11 2021 17:21:51 for libjmmcg by
1.9.2