diff options
author | John Ankarström <john@ankarstrom.se> | 2022-07-15 00:39:07 +0200 |
---|---|---|
committer | John Ankarström <john@ankarstrom.se> | 2022-07-15 00:39:07 +0200 |
commit | 0e22414d042207269f916298b236f1be341ddeea (patch) | |
tree | c7f57ee6882eda6d9a59712f9da753120086bc9e /c/main.cpp | |
parent | 31c03c4ddba65199c8c444c75b684b6cfaa629d9 (diff) | |
download | EpisodeBrowser-0e22414d042207269f916298b236f1be341ddeea.tar.gz |
Add wrapper for LoadLibrary, FreeLibrary.
Diffstat (limited to 'c/main.cpp')
-rw-r--r-- | c/main.cpp | 36 |
1 files changed, 14 insertions, 22 deletions
@@ -3,8 +3,6 @@ #include <uxtheme.h> #include <SWI-Prolog.h> -#include <cstdio> - #include "resource.h" #include "defs.h" @@ -36,26 +34,23 @@ int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, INT nCmdShow) { - HMODULE hModule; LPTSTR tszErr; /* Set constant values. */ - hModule = LoadLibrary(TEXT("uxtheme.dll")); - if (hModule && GetProcAddress(hModule, "SetWindowTheme")) { - g_bThemes = 1; - FreeLibrary(hModule); - } + if (auto upLib = Library::Load(TEXT("uxtheme.dll"))) + if (upLib->GetProcAddress("SetWindowTheme")) { + g_bThemes = 1; + } g_cxVScroll = GetSystemMetrics(SM_CXVSCROLL); /* Setup fonts. */ - hModule = LoadLibrary(TEXT("User32.dll")); - if (hModule && GetProcAddress(hModule, "SystemParametersInfoW")) { - NONCLIENTMETRICS m; - m.cbSize = sizeof(NONCLIENTMETRICS); - SystemParametersInfo(SPI_GETNONCLIENTMETRICS, - sizeof(NONCLIENTMETRICS), &m, 0); - g_hfNormal = CreateFontIndirect(&m.lfMessageFont); - FreeLibrary(hModule); + if (auto upLib = Library::Load(TEXT("User32.dll"))) { + if (upLib->GetProcAddress("SystemParametersInfo" WA)) { + NONCLIENTMETRICS m; + m.cbSize = sizeof(NONCLIENTMETRICS); + SystemParametersInfo(SPI_GETNONCLIENTMETRICS, sizeof(NONCLIENTMETRICS), &m, 0); + g_hfNormal = CreateFontIndirect(&m.lfMessageFont); + } } else g_hfNormal = static_cast<HFONT>(GetStockObject(DEFAULT_GUI_FONT)); @@ -147,12 +142,9 @@ CBTProc(int nCode, WPARAM wParam, LPARAM lParam) g_hWnd = (HWND)wParam; /* Get DPI. */ - UINT (*GetDpiForWindow)(HWND); - HMODULE hModule = LoadLibrary(TEXT("User32.dll")); - if (hModule && (GetDpiForWindow = (UINT (*)(HWND))GetProcAddress(hModule, "GetDpiForWindow"))) { - g_iDPI = GetDpiForWindow(g_hWnd); - FreeLibrary(hModule); - } + if (auto upLib = Library::Load(TEXT("User32.dll"))) + if (auto GetDpiForWindow = (UINT (*)(HWND))upLib->GetProcAddress("GetDpiForWindow")) + g_iDPI = GetDpiForWindow(g_hWnd); /* Create child windows. */ g_lpDlv = new DataListView; |