aboutsummaryrefslogtreecommitdiff
path: root/c/common.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'c/common.cpp')
-rw-r--r--c/common.cpp10
1 files changed, 10 insertions, 0 deletions
diff --git a/c/common.cpp b/c/common.cpp
index fcf1da2..5d786da 100644
--- a/c/common.cpp
+++ b/c/common.cpp
@@ -1,3 +1,4 @@
+#include <utility>
#include <windows.h>
#include "common.h"
@@ -104,6 +105,15 @@ const wchar_t* Win32Error::WhatW() const noexcept
/* Library: Wrapper for loading and freeing dynamically linked libraries. */
+std::optional<Library> Library::Maybe(const wchar_t* const lib)
+{
+ HMODULE hModule = LoadLibrary(lib);
+ if (!hModule) return {};
+ return Library(hModule);
+}
+
+Library::Library(const HMODULE hModule) : m_hModule(hModule) {}
+
Library::Library(const wchar_t* const lib)
{
m_hModule = LoadLibrary(lib);