libfilezilla
Loading...
Searching...
No Matches
dll.hpp
1#ifndef LIBFILEZILLA_GLUE_DLL_HEADER
2#define LIBFILEZILLA_GLUE_DLL_HEADER
3
4#include "../libfilezilla.hpp"
5
6#ifdef FZ_WINDOWS
7
8#include "./windows.hpp"
9
10namespace fz {
11
17class FZ_PUBLIC_SYMBOL dll final
18{
19public:
21 explicit dll(wchar_t const* name, DWORD flags)
22 {
23 h_ = LoadLibraryExW(name, nullptr, flags);
24 }
25
27 ~dll() {
28 if (h_) {
29 FreeLibrary(h_);
30 }
31 }
32
33 dll(dll const&) = delete;
34 dll& operator=(dll const&) = delete;
35
36 explicit operator bool() const {
37 return h_ != nullptr;
38 }
39
45 void *operator[](char const *name) {
46 return h_ ? reinterpret_cast<void*>(::GetProcAddress(h_, name)) : nullptr;
47 }
48
49private:
50 HMODULE h_{};
51};
52
57class FZ_PUBLIC_SYMBOL shdlls final
58{
59protected:
60 shdlls();
61 ~shdlls();
62
63 shdlls(shdlls const&) = delete;
64 shdlls* operator=(shdlls const&) = delete;
65
66public:
67 static shdlls& get();
68
71};
72
73}
74
75#else
76#error This file is for Windows only
77#endif
78
79#endif
80
Encapsulates a DLL.
Definition: dll.hpp:18
~dll()
Closes the library and frees related resources.
Definition: dll.hpp:27
dll(wchar_t const *name, DWORD flags)
Open the specified library with the passed in flags.
Definition: dll.hpp:21
void * operator[](char const *name)
Retrieves the address of an exported symbol in the library.
Definition: dll.hpp:45
A collection of commonly used dlls.
Definition: dll.hpp:58
dll shell32_
The Shell32 DLL.
Definition: dll.hpp:69
dll ole32_
The Ole32 DLL.
Definition: dll.hpp:70
The namespace used by libfilezilla.
Definition: apply.hpp:17