Revert, thx Thomas, wasnt sure.
[reactos.git] / reactos / subsys / system / sm / win32err.c
1 /* $Id: win32err.c 16861 2005-07-29 13:46:03Z ea $
2 *
3 * win32err.c
4 *
5 * Copyright (c) 1998 Mark Russinovich
6 * Systems Internals
7 * http://www.sysinternals.com/
8 *
9 * --------------------------------------------------------------------
10 *
11 * This software is free software; you can redistribute it and/or
12 * modify it under the terms of the GNU Library General Public License as
13 * published by the Free Software Foundation; either version 2 of the
14 * License, or (at your option) any later version.
15 *
16 * This software is distributed in the hope that it will be useful,
17 * but WITHOUT ANY WARRANTY; without even the implied warranty of
18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
19 * Library General Public License for more details.
20 *
21 * You should have received a copy of the GNU Library General Public
22 * License along with this software; see the file COPYING.LIB. If
23 * not, write to the Free Software Foundation, Inc., 675 Mass Ave,
24 * Cambridge, MA 02139, USA.
25 *
26 * --------------------------------------------------------------------
27 *
28 * Print a Win32 error.
29 *
30 * 1999 February (Emanuele Aliberti)
31 * Taken from chkdskx.c and formatx.c by Mark Russinovich
32 * to be used in all sysutils.
33 */
34 #include <windows.h>
35 #include <stdio.h>
36
37 //----------------------------------------------------------------------
38 //
39 // PrintWin32Error
40 //
41 // Takes the win32 error code and prints the text version.
42 //
43 //----------------------------------------------------------------------
44 void
45 PrintWin32Error(
46 PWCHAR Message,
47 DWORD ErrorCode
48 )
49 {
50 PVOID lpMsgBuf;
51
52 FormatMessageW(
53 (FORMAT_MESSAGE_ALLOCATE_BUFFER | FORMAT_MESSAGE_FROM_SYSTEM),
54 NULL,
55 ErrorCode,
56 MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT),
57 (LPWSTR)& lpMsgBuf,
58 0,
59 NULL
60 );
61 wprintf(
62 L"%s: %s\n",
63 Message,
64 lpMsgBuf
65 );
66 LocalFree( lpMsgBuf );
67 }
68
69
70 /* EOF */