]>
Commit | Line | Data |
---|---|---|
fe3a7d70 | 1 | /* |
21006e63 CW |
2 | * lpr for cygwin/windows |
3 | * | |
4 | * Copyright (C) 2000-2003 Rick Rankin | |
5 | * http://www.cygwin.com/ml/cygwin/2000-07/msg00320.html | |
6 | * | |
d76073f1 | 7 | * This program is free software: you can redistribute it and/or modify |
21006e63 | 8 | * it under the terms of the GNU General Public License as published by |
d76073f1 CW |
9 | * the Free Software Foundation, either version 3 of the License, or |
10 | * (at your option) any later version. | |
21006e63 CW |
11 | * |
12 | * This program is distributed in the hope that it will be useful, | |
13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | |
14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
15 | * GNU General Public License for more details. | |
16 | * | |
17 | * You should have received a copy of the GNU General Public License | |
d76073f1 CW |
18 | * along with this program. If not, see <http://www.gnu.org/licenses/>. |
19 | * | |
20 | * See the COPYING file for full license information. | |
21006e63 CW |
21 | */ |
22 | ||
23 | #include "src/lpr/Win32Utils.hh" | |
fe3a7d70 | 24 | using namespace std; |
21006e63 CW |
25 | |
26 | string Win32Utils::getErrorMessage() | |
27 | { | |
28 | return Win32Utils::getErrorMessage(GetLastError()); | |
29 | } | |
30 | ||
31 | string Win32Utils::getErrorMessage(DWORD code) | |
32 | { | |
33 | char * lpMsgBuf; | |
34 | FormatMessage(FORMAT_MESSAGE_ALLOCATE_BUFFER | | |
35 | FORMAT_MESSAGE_FROM_SYSTEM | | |
36 | FORMAT_MESSAGE_IGNORE_INSERTS, | |
37 | NULL, | |
38 | code, | |
39 | MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT), // Default language | |
40 | (LPTSTR) &lpMsgBuf, | |
41 | 0, | |
42 | NULL); | |
43 | ||
44 | string msg = lpMsgBuf; | |
45 | LocalFree(lpMsgBuf); | |
46 | ||
47 | return msg; | |
48 | } | |
49 |