ReactOS
0.4.16-dev-226-g79f2289
win32err.c
Go to the documentation of this file.
1
/*
2
* win32err.c
3
*
4
* Copyright (c) 1998 Mark Russinovich
5
* Systems Internals
6
* http://www.sysinternals.com/
7
*
8
* --------------------------------------------------------------------
9
*
10
* This software is free software; you can redistribute it and/or
11
* modify it under the terms of the GNU Library General Public License as
12
* published by the Free Software Foundation; either version 2 of the
13
* License, or (at your option) any later version.
14
*
15
* This software is distributed in the hope that it will be useful,
16
* but WITHOUT ANY WARRANTY; without even the implied warranty of
17
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
18
* Library General Public License for more details.
19
*
20
* You should have received a copy of the GNU Library General Public
21
* License along with this software; see the file COPYING.LIB. If
22
* not, write to the Free Software Foundation, Inc., 675 Mass Ave,
23
* Cambridge, MA 02139, USA.
24
*
25
* --------------------------------------------------------------------
26
*
27
* Print a Win32 error.
28
*
29
* 1999 February (Emanuele Aliberti)
30
* Taken from chkdskx.c and formatx.c by Mark Russinovich
31
* to be used in all sysutils.
32
*/
33
#include <windows.h>
34
#include <stdio.h>
35
36
//----------------------------------------------------------------------
37
//
38
// PrintWin32Error
39
//
40
// Takes the win32 error code and prints the text version.
41
//
42
//----------------------------------------------------------------------
43
void
44
PrintWin32Error
(
45
PWCHAR
Message
,
46
DWORD
ErrorCode
47
)
48
{
49
LPWSTR
lpMsgBuf;
50
51
FormatMessageW
(
52
(
FORMAT_MESSAGE_ALLOCATE_BUFFER
|
FORMAT_MESSAGE_FROM_SYSTEM
),
53
NULL
,
54
ErrorCode
,
55
MAKELANGID
(
LANG_NEUTRAL
,
SUBLANG_DEFAULT
),
56
(
LPWSTR
)& lpMsgBuf,
57
0,
58
NULL
59
);
60
wprintf
(
61
L
"%s: %s\n"
,
62
Message
,
63
lpMsgBuf
64
);
65
LocalFree
( lpMsgBuf );
66
}
67
68
69
/* EOF */
NULL
#define NULL
Definition:
types.h:112
FormatMessageW
DWORD WINAPI FormatMessageW(DWORD dwFlags, LPCVOID lpSource, DWORD dwMessageId, DWORD dwLanguageId, LPWSTR lpBuffer, DWORD nSize, __ms_va_list *args)
Definition:
format_msg.c:583
Message
static const WCHAR Message[]
Definition:
register.c:74
DWORD
unsigned long DWORD
Definition:
ntddk_ex.h:95
LocalFree
HLOCAL NTAPI LocalFree(HLOCAL hMem)
Definition:
heapmem.c:1594
ErrorCode
_In_ NDIS_ERROR_CODE ErrorCode
Definition:
ndis.h:4436
L
#define L(x)
Definition:
ntvdm.h:50
LANG_NEUTRAL
#define LANG_NEUTRAL
Definition:
nls.h:22
MAKELANGID
#define MAKELANGID(p, s)
Definition:
nls.h:15
SUBLANG_DEFAULT
#define SUBLANG_DEFAULT
Definition:
nls.h:168
PWCHAR
uint16_t * PWCHAR
Definition:
typedefs.h:56
wprintf
#define wprintf(...)
Definition:
whoami.c:18
PrintWin32Error
void PrintWin32Error(PWCHAR Message, DWORD ErrorCode)
Definition:
win32err.c:44
FORMAT_MESSAGE_FROM_SYSTEM
#define FORMAT_MESSAGE_FROM_SYSTEM
Definition:
winbase.h:448
FORMAT_MESSAGE_ALLOCATE_BUFFER
#define FORMAT_MESSAGE_ALLOCATE_BUFFER
Definition:
winbase.h:444
LPWSTR
WCHAR * LPWSTR
Definition:
xmlstorage.h:184
modules
rosapps
lib
win32err
win32err.c
Generated on Sun Nov 3 2024 06:09:09 for ReactOS by
1.9.6