From 1effc94df7e558de6319082e390803911cf45c24 Mon Sep 17 00:00:00 2001 From: Mike Buland Date: Wed, 12 Jan 2011 19:27:48 +0000 Subject: Plugger, and potentially anything that can use windows, can report windows errors now...uh...woo? --- src/compat/win32.cpp | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) (limited to 'src/compat/win32.cpp') diff --git a/src/compat/win32.cpp b/src/compat/win32.cpp index 6fcac15..052644a 100644 --- a/src/compat/win32.cpp +++ b/src/compat/win32.cpp @@ -162,5 +162,27 @@ int Bu::Winsock2::__WSAFDIsSet( SOCKET s, fd_set *set ) { return (*Bu::Winsock2::_fnptr___WSAFDIsSet)( s, set ); } +Bu::FString Bu::getLastWinError() +{ + LPVOID lpMsgBuf; + DWORD dw = GetLastError(); + + FormatMessageA( + FORMAT_MESSAGE_ALLOCATE_BUFFER | + FORMAT_MESSAGE_FROM_SYSTEM | + FORMAT_MESSAGE_IGNORE_INSERTS, + NULL, + dw, + MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT), + (LPSTR) &lpMsgBuf, + 0, NULL ); + + Bu::FString sRet( (char *)lpMsgBuf ); + + LocalFree(lpMsgBuf); + + return sRet; +} + #endif -- cgit v1.2.3