#ifndef COMMON_H #define COMMON_H #include #include #include #include TCHAR *TszFromSz(const char *, int); struct Win32Error : public std::exception { Win32Error(DWORD); ~Win32Error(void); virtual const char *what(void) const noexcept override; private: DWORD m_dwErr; char *m_szMsg = NULL; }; struct Library { Library(const TCHAR *); ~Library(void); FARPROC GetProcAddress(const char *); private: HMODULE m_hModule; }; #ifdef UNICODE #define WA "W" #else #define WA "A" #endif inline int Cmp(int a, int b) { if (a == b) return 0; if (a > b) return 1; return -1; } inline int Dpi(int i) { extern int g_iDPI; return MulDiv(i, g_iDPI, 96); } template std::optional try_make(A ...args) { try { return T(args...); } catch (...) { return {}; } } #endif