CVB++ 15.0
detail_dyn_loader_windows.hpp
1#pragma once
2
3#include <vector>
4
5#include "../global.hpp"
6#include "../string.hpp"
7
8#include "detail_dyn_loader.hpp"
9
10#ifndef NOMINMAX
11# define NOMINMAX
12#endif
13#include <Windows.h>
14
15namespace Cvb
16{
17
18 CVB_BEGIN_INLINE_NS
19
20 namespace Internal
21 {
22
23 inline DynLoader::DynLoader(const String &name)
24 {
25 auto fileName = name + CVB_LIT(".dll");
26 handle_ = LoadLibrary(fileName.c_str());
27 if (!handle_)
28 throw std::runtime_error("failed to load module");
29 }
30
31 inline DynLoader::~DynLoader()
32 {
33 FreeLibrary(reinterpret_cast<HMODULE>(handle_));
34 }
35
36 inline void *DynLoader::LoadSymbol(const String &name) noexcept
37 {
38 std::string cname(Internal::CastToAscii(name));
39 return GetProcAddress(reinterpret_cast<HMODULE>(handle_), cname.c_str());
40 }
41
42 } // namespace Internal
43
44 CVB_END_INLINE_NS
45
46} // namespace Cvb
Root namespace for the Image Manager interface.
Definition c_bayer_to_rgb.h:17
std::string String
String for wide characters or unicode characters.
Definition string.hpp:49