If I call a Win32 function that reports errors via GetLastError, for example RegisterClassEx, how do I throw a std::system_error for that error?
Check on the value of GetLastError() like
GetLastError()
DWORD dwErrVal = GetLastError(); std::error_code ec (dwErrVal, std::system_category()); throw std::system_error(ec, "Exception occurred");
See here for error_code and here for std::system_error.
error_code
std::system_error