diff options
Diffstat (limited to 'c/common.h')
-rw-r--r-- | c/common.h | 30 |
1 files changed, 18 insertions, 12 deletions
@@ -27,23 +27,15 @@ struct Library { Library(const TCHAR* tszLibrary); ~Library(); - void* GetProcAddress(const char* szProc); + template <typename T> T* GetProcAddress(const char* szProc); private: HMODULE m_hModule; }; -inline int Cmp(const int a, const int b) +template <typename T> +T* Library::GetProcAddress(const char* const szProc) { - if (a == b) return 0; - if (a > b) return 1; - return -1; -} - -/* Return integer scaled for current DPI. */ -inline int Dpi(const int i) -{ - extern int g_iDPI; - return MulDiv(i, g_iDPI, 96); + return (T*)(void*)::GetProcAddress(m_hModule, szProc); } /* Create and return an object of type C. If construction fails, @@ -59,4 +51,18 @@ std::optional<C> try_make(T ...args) } } +/* Return integer scaled for current DPI. */ +inline int Dpi(const int i) +{ + extern int g_iDPI; + return MulDiv(i, g_iDPI, 96); +} + +inline int Cmp(const int a, const int b) +{ + if (a == b) return 0; + if (a > b) return 1; + return -1; +} + #endif |