forked from microsoft/PowerToys
-
Notifications
You must be signed in to change notification settings - Fork 0
/
powertoy_module.h
53 lines (43 loc) · 1.1 KB
/
powertoy_module.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
#pragma once
#include <interface/powertoy_module_interface.h>
#include <string>
#include <memory>
#include <mutex>
#include <vector>
#include <functional>
#include <common/utils/json.h>
struct PowertoyModuleDeleter
{
void operator()(PowertoyModuleIface* pt_module) const
{
if (pt_module)
{
pt_module->destroy();
}
}
};
struct PowertoyModuleDLLDeleter
{
using pointer = HMODULE;
void operator()(HMODULE handle) const
{
FreeLibrary(handle);
}
};
class PowertoyModule
{
public:
PowertoyModule(PowertoyModuleIface* pt_module, HMODULE handle);
inline PowertoyModuleIface* operator->()
{
return pt_module.get();
}
json::JsonObject json_config() const;
void update_hotkeys();
void UpdateHotkeyEx();
private:
std::unique_ptr<HMODULE, PowertoyModuleDLLDeleter> handle;
std::unique_ptr<PowertoyModuleIface, PowertoyModuleDeleter> pt_module;
};
PowertoyModule load_powertoy(const std::wstring_view filename);
std::map<std::wstring, PowertoyModule>& modules();