VirtualBox

source: kBuild/trunk/src/gmake/w32/subproc/w32err.c@ 285

Last change on this file since 285 was 285, checked in by bird, 20 years ago

This commit was generated by cvs2svn to compensate for changes in r284,
which included commits to RCS files with non-trunk default branches.

  • Property svn:eol-style set to native
File size: 1.2 KB
Line 
1#include <windows.h>
2#include "w32err.h"
3
4/*
5 * Description: the windows32 version of perror()
6 *
7 * Returns: a pointer to a static error
8 *
9 * Notes/Dependencies: I got this from
10 * comp.os.ms-windows.programmer.win32
11 */
12char *
13map_windows32_error_to_string (DWORD ercode) {
14/* __declspec (thread) necessary if you will use multiple threads on MSVC */
15#ifdef _MSC_VER
16__declspec (thread) static char szMessageBuffer[128];
17#else
18static char szMessageBuffer[128];
19#endif
20 /* Fill message buffer with a default message in
21 * case FormatMessage fails
22 */
23 wsprintf (szMessageBuffer, "Error %ld\n", ercode);
24
25 /*
26 * Special code for winsock error handling.
27 */
28 if (ercode > WSABASEERR) {
29 HMODULE hModule = GetModuleHandle("wsock32");
30 if (hModule != NULL) {
31 FormatMessage(FORMAT_MESSAGE_FROM_HMODULE,
32 hModule,
33 ercode,
34 LANG_NEUTRAL,
35 szMessageBuffer,
36 sizeof(szMessageBuffer),
37 NULL);
38 FreeLibrary(hModule);
39 }
40 } else {
41 /*
42 * Default system message handling
43 */
44 FormatMessage(FORMAT_MESSAGE_FROM_SYSTEM,
45 NULL,
46 ercode,
47 LANG_NEUTRAL,
48 szMessageBuffer,
49 sizeof(szMessageBuffer),
50 NULL);
51 }
52 return szMessageBuffer;
53}
54
Note: See TracBrowser for help on using the repository browser.

© 2025 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette