Advertisement
ddto

Untitled

Aug 14th, 2024
89
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.37 KB | None | 0 0
  1. #pragma once
  2.  
  3. // include this instead of including Windows.h directly
  4.  
  5. #define _WIN32_WINNT 0x0601
  6. #include <sdkddkver.h>
  7.  
  8. #ifndef WINDOWS_FULL
  9. #define WIN32_LEAN_AND_MEAN
  10. #define NOGDICAPMASKS
  11. #define NOSYSMETRICS
  12. #define NOMENUS
  13. #define NOICONS
  14. #define NOSYSCOMMANDS
  15. #define NORASTEROPS
  16. #define OEMRESOURCE
  17. #define NOATOM
  18. #define NOCLIPBOARD
  19. #define NOCOLOR
  20. #define NOCTLMGR
  21. #define NODRAWTEXT
  22. #define NOKERNEL
  23. //#define NONLS
  24. #define NOMEMMGR
  25. #define NOMETAFILE
  26. #define NOOPENFILE
  27. #define NOSCROLL
  28. #define NOSERVICE
  29. #define NOSOUND
  30. #define NOTEXTMETRIC
  31. #define NOWH
  32. #define NOCOMM
  33. #define NOKANJI
  34. #define NOHELP
  35. #define NOPROFILER
  36. #define NODEFERWINDOWPOS
  37. #define NOMCX
  38. #define NORPC
  39. #define NOPROXYSTUB
  40. #define NOIMAGE
  41. #define NOTAPE
  42. #endif
  43.  
  44. #define NOMINMAX
  45. #define STRICT
  46.  
  47. #if defined(_WIN64) || defined(_WIN32)
  48. #include <Windows.h>
  49.  
  50. inline String GetLastErrorStr()
  51. {
  52.     DWORD errorMessageID = GetLastError();
  53.     if (errorMessageID == 0) return String();
  54.  
  55.     LPSTR messageBuffer = nullptr;
  56.  
  57.     size_t size = FormatMessageA(FORMAT_MESSAGE_ALLOCATE_BUFFER | FORMAT_MESSAGE_FROM_SYSTEM | FORMAT_MESSAGE_IGNORE_INSERTS,
  58.         NULL, errorMessageID, MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT), (LPSTR)&messageBuffer, 0, NULL);
  59.    
  60.     String message(messageBuffer, size);
  61.     LocalFree(messageBuffer);
  62.     return message;
  63. }
  64. #endif
  65.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement