Back to index

nordugrid-arc-nox  1.1.0~rc6
win32.cpp
Go to the documentation of this file.
00001 // -*- indent-tabs-mode: nil -*-
00002 
00003 #ifdef HAVE_CONFIG_H
00004 #include <config.h>
00005 #endif
00006 
00007 #include "win32.h"
00008 
00009 std::string GetOsErrorMessage(void) {
00010   std::string rv;
00011   LPVOID lpMsgBuf;
00012   if (FormatMessage(
00013         FORMAT_MESSAGE_ALLOCATE_BUFFER | FORMAT_MESSAGE_FROM_SYSTEM | FORMAT_MESSAGE_IGNORE_INSERTS,
00014         NULL,
00015         GetLastError(),
00016         MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT), // Default language
00017         (LPTSTR)&lpMsgBuf,
00018         0,
00019         NULL))
00020     rv.assign(reinterpret_cast<const char*>(lpMsgBuf));
00021   else
00022     rv.assign("FormatMessage API failed");
00023   LocalFree(lpMsgBuf);
00024   return rv;
00025 }