8 ms·
Oh wow, this is exactly what I've always wanted in my many many years of developing Windows software in C++. Despite a million fancy new API layers in newer ve
by TillE 7y ago
Oh wow, this is exactly what I've always wanted in my many many years of developing Windows software in C++.
Despite a million fancy new API layers in newer versions of Windows, Win32 is very much not dead, but it's still a C interface with a lot of clunky and inconsistent nonsense. This looks like the ideal modern C++ wrapper for all that.
- stinos 7y agoIt looks pretty usable indeed, I just wish they had insludes std::error_code implementations for everything. Last time I checked, getting proper error_codes (i.e. which can be compared against standard categories and which have good error description strings) for everything in the API was still some manual work.
- aninteger 7y agoIt's not too hard. Just write a simple wrapper around FormatMessage: DWORD errorCode = GetLastError(); DWORD dwFlg = FORMAT_MESSAGE_ALLOCATE_BUFFER | FORMAT_MESSAGE_FROM_SYSTEM | FORMAT_MESSAGE_IGNORE_INSERTS; LPTSTR lpMsgBuf = NULL; FormatMessageA(dwFlg, 0, errorCode, 0, (LPTSTR)&lpMsgBuf, 0, NULL); // Error message is in lpMsgBuf so make sure to free afterwards. LocalFree(lpMsgBuf);
- ksherlock 7y agoIt's even easier since the MSVC STL std::error_code (std::system_category) already does that.