WindowsUtils.hpp 989 B

12345678910111213141516171819202122232425262728293031323334353637383940
  1. /*
  2. * Author: Patrick-Christopher Mattulat
  3. * Company: Lynar Studios
  4. * E-Mail: webmaster@lynarstudios.com
  5. * Created: 2020-12-06
  6. * Changed: 2020-12-06
  7. *
  8. * */
  9. #ifndef LS_STD_WINDOWS_UTILS_HPP
  10. #define LS_STD_WINDOWS_UTILS_HPP
  11. #include <ls_std/base/Types.hpp>
  12. #include <string>
  13. #include <windows.h>
  14. namespace ls_std {
  15. class WindowsUtils {
  16. public:
  17. WindowsUtils() = default;
  18. ~WindowsUtils() = default;
  19. static std::string getMessageFromErrorCode(const int& _errorCode) {
  20. ls_std::byte messageBuffer[256 + 1];
  21. FormatMessage (FORMAT_MESSAGE_FROM_SYSTEM | FORMAT_MESSAGE_IGNORE_INSERTS,
  22. nullptr,
  23. _errorCode,
  24. MAKELANGID (LANG_NEUTRAL, SUBLANG_DEFAULT),
  25. messageBuffer,
  26. sizeof (messageBuffer),
  27. nullptr);
  28. return std::string {messageBuffer};
  29. }
  30. };
  31. }
  32. #endif