summaryrefslogtreecommitdiff
path: root/src/libcrawler/win32/errormsg.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/libcrawler/win32/errormsg.cpp')
-rwxr-xr-xsrc/libcrawler/win32/errormsg.cpp27
1 files changed, 27 insertions, 0 deletions
diff --git a/src/libcrawler/win32/errormsg.cpp b/src/libcrawler/win32/errormsg.cpp
new file mode 100755
index 0000000..c0a65d8
--- /dev/null
+++ b/src/libcrawler/win32/errormsg.cpp
@@ -0,0 +1,27 @@
+#include "win32/errormsg.hpp"
+
+using namespace std;
+
+#define WIN32_MEAN_AND_LEAN
+#include <windows.h>
+
+string getLastError( )
+{
+ LPTSTR buf;
+ DWORD size;
+
+ DWORD lastErr = GetLastError( );
+
+ if( !FormatMessage(
+ FORMAT_MESSAGE_ALLOCATE_BUFFER |
+ FORMAT_MESSAGE_FROM_SYSTEM |
+ FORMAT_MESSAGE_IGNORE_INSERTS |
+ FORMAT_MESSAGE_MAX_WIDTH_MASK,
+ NULL, lastErr, 0, (LPTSTR)&buf,
+ 0, NULL ) ) {
+ return "<no message available>";
+ }
+
+ return string( buf );
+}
+