WindowsUtils.hpp 976 B

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