WindowsUtils.hpp 884 B

123456789101112131415161718192021222324252627282930313233343536
  1. /*
  2. * Author: Patrick-Christopher Mattulat
  3. * Company: Lynar Studios
  4. * E-Mail: webmaster@lynarstudios.com
  5. * Created: 2020-12-06
  6. * Changed: 2022-07-02
  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::std::core
  15. {
  16. class WindowsUtils
  17. {
  18. public:
  19. WindowsUtils() = default;
  20. ~WindowsUtils() = default;
  21. static ::std::string getMessageFromErrorCode(const int &_errorCode)
  22. {
  23. ls::std::core::type::byte messageBuffer[256 + 1];
  24. FormatMessage(FORMAT_MESSAGE_FROM_SYSTEM | FORMAT_MESSAGE_IGNORE_INSERTS, nullptr, _errorCode, MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT), messageBuffer, sizeof(messageBuffer), nullptr);
  25. return ::std::string{messageBuffer};
  26. }
  27. };
  28. }
  29. #endif