diff options
author | Alexander Gottwald <alexander.gottwald@s1999.tu-chemnitz.de> | 2004-04-27 18:07:15 +0000 |
---|---|---|
committer | Alexander Gottwald <alexander.gottwald@s1999.tu-chemnitz.de> | 2004-04-27 18:07:15 +0000 |
commit | 9a6e22ebfb4f93b240e42249a230d76afc041216 (patch) | |
tree | 1f78bec1d11d713495284d798114d5e88bc84ac2 | |
parent | 11fb48f46349feb0520c95f957cfa326dd50ca0f (diff) |
new function winW32Error which prints the error string with FormatMessage
-rw-r--r-- | hw/xwin/winmsg.c | 24 | ||||
-rw-r--r-- | hw/xwin/winmsg.h | 1 |
2 files changed, 25 insertions, 0 deletions
diff --git a/hw/xwin/winmsg.c b/hw/xwin/winmsg.c index e9d72b7f6..23252612c 100644 --- a/hw/xwin/winmsg.c +++ b/hw/xwin/winmsg.c @@ -101,3 +101,27 @@ winDebug (const char *format, ...) LogVMessageVerb(X_NONE, 3, format, ap); va_end (ap); } + +void +winW32Error(int verb, DWORD errorcode, const char *format) +{ + LPVOID buffer; + if (!FormatMessage( + FORMAT_MESSAGE_ALLOCATE_BUFFER | + FORMAT_MESSAGE_FROM_SYSTEM | + FORMAT_MESSAGE_IGNORE_INSERTS, + NULL, + errorcode, + MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT), + (LPTSTR) &buffer, + 0, + NULL )) + { + winErrorFVerb(verb, "Unknown error in FormatMessage!\n"); + } + else + { + winErrorFVerb(verb, format, (char *)buffer); + LocalFree(buffer); + } +} diff --git a/hw/xwin/winmsg.h b/hw/xwin/winmsg.h index 7ceb73858..a42d6467c 100644 --- a/hw/xwin/winmsg.h +++ b/hw/xwin/winmsg.h @@ -44,5 +44,6 @@ void winMsg (MessageType type, const char *format, ...); void winDebug (const char *format, ...); void winErrorFVerb (int verb, const char *format, ...); +void winW32Error(int verb, DWORD errorcode, const char *format); #endif |