]> cygwin.com Git - cygwin-apps/cygutils.git/blob - src/lpr/Win32Utils.cc
9c55376f28e76f32beb66b07156dd027b74e1e2e
[cygwin-apps/cygutils.git] / src / lpr / Win32Utils.cc
1 /*
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 *
7 * This program is free software: you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by
9 * the Free Software Foundation, either version 3 of the License, or
10 * (at your option) any later version.
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
18 * along with this program. If not, see <http://www.gnu.org/licenses/>.
19 *
20 * See the COPYING file for full license information.
21 */
22
23 #include "src/lpr/Win32Utils.hh"
24 using namespace std;
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
This page took 0.054643 seconds and 6 git commands to generate.